Use WARNING() for warnings instead of ERROR().
authorEric Biggers <ebiggers3@gmail.com>
Fri, 18 May 2012 01:58:00 +0000 (20:58 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 18 May 2012 01:58:00 +0000 (20:58 -0500)
src/util.c
src/util.h
src/wim.c
src/write.c

index d091c3e155fba957bd57d38fd72b1131cba7100d..64b8c667c27635103b7e8537ef0ea42fe7f10385 100644 (file)
@@ -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)
index e1a0d3118a2e1dfd83c443e81652b8669949eadf..5385477f0403e267dfd69c4e8e83e860173ff202 100644 (file)
@@ -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)
index f7d9eaccf38107277466d04cc97693a72007c5dd..b8ee8fb81e400a4d378a5991e19365f5dee27866 100644 (file)
--- 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");
index 45b4993f5d3baa43f9cedec76afa3a444ade0408..94e4fc9fea04700bfb08c198554484d033bf1843 100644 (file)
@@ -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;