From ff7a2e6e4917657a67759b25f8c4f41ce085c3c7 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 30 Dec 2017 09:09:12 +0100 Subject: Format errors --- src/common.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h index 7a9c555..a45b6f4 100644 --- a/src/common.h +++ b/src/common.h @@ -26,16 +26,18 @@ store32_le(uint8_t dst[4], uint32_t w) } static void -die(const char *msg) +die(int print_errno, const char *format, ...) { - fprintf(stderr, "%s\n", msg); - exit(1); -} + va_list ap; + + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + if (print_errno) { + fprintf(stderr, "- %s", strerror(errno)); + } + fprintf(stderr, "\n"); -static void -diex(const char *msg) -{ - perror(msg); exit(1); } -- cgit v1.2.3-70-g09d2