From aa94050e96590cdd4d74d467eb77055efa1fa14a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 15 Sep 2016 23:25:49 -0400 Subject: Use err(3) in xx --- .bin/xx.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.bin/xx.c b/.bin/xx.c index 9b8f5d0f..00b55391 100755 --- a/.bin/xx.c +++ b/.bin/xx.c @@ -3,6 +3,7 @@ exec clang -Weverything -Wno-vla $@ -o $(dirname $0)/xx $0 #endif #include +#include #include #include #include @@ -50,10 +51,7 @@ int main(int argc, char **argv) { path = argv[optind]; FILE *file = path ? fopen(path, "r") : stdin; - if (!file) { - perror(path); - return EX_NOINPUT; - } + if (!file) err(EX_NOINPUT, "%s", path); uint8_t buf[cols]; size_t offset = 0, len = 0, i; @@ -92,9 +90,6 @@ int main(int argc, char **argv) { if (len < sizeof(buf)) break; } - if (ferror(file)) { - perror(path); - return EX_IOERR; - } + if (ferror(file)) err(EX_IOERR, "%s", path); return EX_OK; } -- cgit 1.4.1