diff --git a/src/dj.c b/src/dj.c index e4ddd71..ad1dc49 100644 --- a/src/dj.c +++ b/src/dj.c @@ -108,8 +108,10 @@ Io_write(struct Io *io) { } static int -oserr(char *e, int n) { - (void)fprintf(stderr, "%s: %s: %s\n", program_name, e, strerror(n)); +oserr(char *e, int n) { /* program_name: [failing component:] error */ + (void)fprintf(stderr, "%s: ", program_name); + if (e != NULL) { (void)fprintf(stderr, "%s: ", e); } + (void)fprintf(stderr, "%s\n", strerror(n)); return EX_OSERR; } @@ -170,7 +172,7 @@ usage(char *argv0) { int main(int argc, char *argv[]) { #ifdef __OpenBSD__ if (pledge("cpath rpath stdio unveil wpath", NULL) == -1) { - return oserr("pledge", errno); + return oserr(NULL", errno); } #endif @@ -222,7 +224,7 @@ int main(int argc, char *argv[]) { if (i == 0) { perms = "r"; } if (unveil(optarg, perms) == -1) { - return oserr("unveil", errno); + return oserr(NULL, errno); } #endif @@ -266,7 +268,7 @@ int main(int argc, char *argv[]) { } } #ifdef __OpenBSD__ - if (unveil(NULL, NULL) == -1) { return oserr("unveil", errno); } + if (unveil(NULL, NULL) == -1) { return oserr(NULL, errno); } #endif assert(io->fd != STDIN_FILENO || io->fl == read_flags);