From c167021d72fc6987572ccfbb81f5ca9f6f833afc Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 17 May 2012 20:58:00 -0500 Subject: [PATCH] Use WARNING() for warnings instead of ERROR(). --- src/util.c | 16 ++++++++++++++++ src/util.h | 3 +++ src/wim.c | 9 ++++----- src/write.c | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/util.c b/src/util.c index d091c3e1..64b8c667 100644 --- a/src/util.c +++ b/src/util.c @@ -53,6 +53,22 @@ void wimlib_error(const char *format, ...) va_end(va); } } + +void wimlib_warning(const char *format, ...) +{ + if (__wimlib_print_errors) { + va_list va; + int errno_save; + + va_start(va, format); + errno_save = errno; + fputs("WARNING: ", stderr); + vfprintf(stderr, format, va); + errno = errno_save; + va_end(va); + } +} + #endif WIMLIBAPI int wimlib_set_print_errors(bool show_error_messages) diff --git a/src/util.h b/src/util.h index e1a0d311..5385477f 100644 --- a/src/util.h +++ b/src/util.h @@ -51,9 +51,12 @@ typedef unsigned uint; #ifdef ENABLE_ERROR_MESSAGES extern bool __wimlib_print_errors; extern void wimlib_error(const char *format, ...); +extern void wimlib_warning(const char *format, ...); # define ERROR wimlib_error +# define WARNING wimlib_warning #else # define ERROR(format, ...) +# define WARNING(format, ...) #endif /* ENABLE_ERROR_MESSAGES */ #if defined(ENABLE_DEBUG) || defined(ENABLE_MORE_DEBUG) diff --git a/src/wim.c b/src/wim.c index f7d9eacc..b8ee8fb8 100644 --- a/src/wim.c +++ b/src/wim.c @@ -409,10 +409,9 @@ static int wim_begin_read(WIMStruct *w, const char *in_wim_path, int flags) /* If the boot index is invalid, print a warning and set it to 0 */ if (w->hdr.boot_idx > w->hdr.image_count) { - ERROR("WARNING: In `%s', image %u is marked as bootable,\n", - in_wim_path, w->hdr.boot_idx); - ERROR(" but there are only %u images!\n", - w->hdr.image_count); + WARNING("In `%s', image %u is marked as bootable,\n" + "\tbut there are only %u images!\n", + in_wim_path, w->hdr.boot_idx, w->hdr.image_count); w->hdr.boot_idx = 0; } @@ -433,7 +432,7 @@ static int wim_begin_read(WIMStruct *w, const char *in_wim_path, int flags) goto done; } if (integrity_status == WIM_INTEGRITY_NONEXISTENT) { - DEBUG("WARNING: No integrity information; skipping " + WARNING("No integrity information; skipping " "integrity check.\n"); } else if (integrity_status == WIM_INTEGRITY_NOT_OK) { ERROR("WIM is not intact! (Failed integrity check)\n"); diff --git a/src/write.c b/src/write.c index 45b4993f..94e4fc9f 100644 --- a/src/write.c +++ b/src/write.c @@ -530,7 +530,7 @@ WIMLIBAPI int wimlib_overwrite(WIMStruct *w, int flags) /* Close the original WIM file that was opened for reading. */ if (w->fp) { if (fclose(w->fp) != 0) { - DEBUG("WARNING: Failed to close the file `%s'\n", + WARNING("Failed to close the file `%s'\n", wimfile_name); } w->fp = NULL; -- 2.43.0