diff options
author | Ben Pfaff <blp@nicira.com> | 2011-03-31 14:50:58 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-04-29 14:31:31 -0700 |
commit | c84933bf9a73e334207b6b309749d9e9c3b04812 (patch) | |
tree | 33ffd789e3a7a0dcac7dcaf83cb84378040db5a5 | |
parent | 83ddfb6b48053f0fe202e5f7934e60b81720952b (diff) |
util: New function ovs_fatal_valist().
This commit adds a few initial users but more are coming up.
-rw-r--r-- | lib/util.c | 9 | ||||
-rw-r--r-- | lib/util.h | 2 | ||||
-rw-r--r-- | utilities/ovs-dpctl.c | 11 | ||||
-rw-r--r-- | utilities/ovs-ofctl.c | 11 |
4 files changed, 11 insertions, 22 deletions
@@ -204,9 +204,14 @@ ovs_fatal(int err_no, const char *format, ...) va_list args; va_start(args, format); - ovs_error_valist(err_no, format, args); - va_end(args); + ovs_fatal_valist(err_no, format, args); +} +/* Same as ovs_fatal() except that the arguments are supplied as a va_list. */ +void +ovs_fatal_valist(int err_no, const char *format, va_list args) +{ + ovs_error_valist(err_no, format, args); exit(EXIT_FAILURE); } @@ -155,6 +155,8 @@ void ovs_abort(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3) NO_RETURN; void ovs_fatal(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3) NO_RETURN; +void ovs_fatal_valist(int err_no, const char *format, va_list) + PRINTF_FORMAT(2, 0) NO_RETURN; void ovs_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3); void ovs_error_valist(int err_no, const char *format, va_list) PRINTF_FORMAT(2, 0); diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index f3e13a70..9d6bf985 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -146,17 +146,8 @@ static void run(int retval, const char *message, ...) if (retval) { va_list args; - fprintf(stderr, "%s: ", program_name); va_start(args, message); - vfprintf(stderr, message, args); - va_end(args); - if (retval == EOF) { - fputs(": unexpected end of file\n", stderr); - } else { - fprintf(stderr, ": %s\n", strerror(retval)); - } - - exit(EXIT_FAILURE); + ovs_fatal_valist(retval, message, args); } } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 201a9633..994329e6 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -199,17 +199,8 @@ static void run(int retval, const char *message, ...) if (retval) { va_list args; - fprintf(stderr, "%s: ", program_name); va_start(args, message); - vfprintf(stderr, message, args); - va_end(args); - if (retval == EOF) { - fputs(": unexpected end of file\n", stderr); - } else { - fprintf(stderr, ": %s\n", strerror(retval)); - } - - exit(EXIT_FAILURE); + ovs_fatal_valist(retval, message, args); } } |