diff options
author | Mark Whitley | 2000-12-05 19:27:13 +0000 |
---|---|---|
committer | Mark Whitley | 2000-12-05 19:27:13 +0000 |
commit | cf61fe14aebf2b5f753261afdb9e03167b31a843 (patch) | |
tree | a92c9df4e2fc08bd7f1b3798214a30cbd50a2e52 | |
parent | d27753afd983ffeae45b80dee92f02d0518ca7bf (diff) | |
download | busybox-cf61fe14aebf2b5f753261afdb9e03167b31a843.zip busybox-cf61fe14aebf2b5f753261afdb9e03167b31a843.tar.gz |
Applied patch from Matt Kraai to add v*error functions for handling vararg
lists in a safe 'n sane fashion.
-rw-r--r-- | utility.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -84,36 +84,35 @@ extern void usage(const char *usage) exit(EXIT_FAILURE); } -extern void errorMsg(const char *s, ...) +static void verrorMsg(const char *s, va_list p) { - va_list p; - - va_start(p, s); fflush(stdout); fprintf(stderr, "%s: ", applet_name); vfprintf(stderr, s, p); - va_end(p); fflush(stderr); } -extern void fatalError(const char *s, ...) +extern void errorMsg(const char *s, ...) { va_list p; va_start(p, s); - fflush(stdout); - fprintf(stderr, "%s: ", applet_name); - vfprintf(stderr, s, p); + verrorMsg(s, p); va_end(p); - fflush(stderr); - exit(EXIT_FAILURE); } -extern void perrorMsg(const char *s, ...) +extern void fatalError(const char *s, ...) { va_list p; va_start(p, s); + verrorMsg(s, p); + va_end(p); + exit(EXIT_FAILURE); +} + +static void vperrorMsg(const char *s, va_list p) +{ fflush(stdout); fprintf(stderr, "%s: ", applet_name); if (s && *s) { @@ -121,24 +120,25 @@ extern void perrorMsg(const char *s, ...) fputs(": ", stderr); } fprintf(stderr, "%s\n", strerror(errno)); - va_end(p); fflush(stderr); } +extern void perrorMsg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + vperrorMsg(s, p); + va_end(p); +} + extern void fatalPerror(const char *s, ...) { va_list p; va_start(p, s); - fflush(stdout); - fprintf(stderr, "%s: ", applet_name); - if (s && *s) { - vfprintf(stderr, s, p); - fputs(": ", stderr); - } - fprintf(stderr, "%s\n", strerror(errno)); + vperrorMsg(s, p); va_end(p); - fflush(stderr); exit(EXIT_FAILURE); } |