summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2016-09-15 23:25:49 -0400
committerJune McEnroe <programble@gmail.com>2016-09-15 23:25:49 -0400
commitaa94050e96590cdd4d74d467eb77055efa1fa14a (patch)
treeff06c6391a9432133f6fe893380ff500ea00d9b6
parentUse sysexits.h in xx (diff)
downloadsrc-aa94050e96590cdd4d74d467eb77055efa1fa14a.tar.gz
src-aa94050e96590cdd4d74d467eb77055efa1fa14a.zip
Use err(3) in xx
-rwxr-xr-x.bin/xx.c11
1 files 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 <ctype.h>
+#include <err.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -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;
 }