]> wimlib.net Git - wimlib/blobdiff - src/write.c
Refactor error functions; make re-entrant
[wimlib] / src / write.c
index 86730ff7fec7a1158b6ed8bed305ec784b9375aa..4b06146fe27c4c1a8766c4f2ca24fa8688818bd1 100644 (file)
@@ -1265,8 +1265,8 @@ out_join:
 
        for (unsigned i = 0; i < num_threads; i++) {
                if (pthread_join(compressor_threads[i], NULL)) {
 
        for (unsigned i = 0; i < num_threads; i++) {
                if (pthread_join(compressor_threads[i], NULL)) {
-                       WARNING("Failed to join compressor thread %u: %s",
-                               i, strerror(errno));
+                       WARNING_WITH_ERRNO("Failed to join compressor "
+                                          "thread %u", i);
                }
        }
        FREE(compressor_threads);
                }
        }
        FREE(compressor_threads);
@@ -1353,8 +1353,10 @@ static int lte_overwrite_prepare(struct wim_lookup_table_entry *lte, void *arg)
            lte->wim == args->wim &&
            lte->resource_entry.offset + lte->resource_entry.size > args->end_offset)
        {
            lte->wim == args->wim &&
            lte->resource_entry.offset + lte->resource_entry.size > args->end_offset)
        {
+       #ifdef ENABLE_ERROR_MESSAGES
                ERROR("The following resource is after the XML data:");
                ERROR("The following resource is after the XML data:");
-               print_lookup_table_entry(lte);
+               print_lookup_table_entry(lte, stderr);
+       #endif
                return WIMLIB_ERR_RESOURCE_ORDER;
        }
 
                return WIMLIB_ERR_RESOURCE_ORDER;
        }
 
@@ -1601,8 +1603,8 @@ int lock_wim(WIMStruct *w, FILE *fp)
                                      "        by another process!", w->filename);
                                ret = WIMLIB_ERR_ALREADY_LOCKED;
                        } else {
                                      "        by another process!", w->filename);
                                ret = WIMLIB_ERR_ALREADY_LOCKED;
                        } else {
-                               WARNING("Failed to lock `%s': %s",
-                                       w->filename, strerror(errno));
+                               WARNING_WITH_ERRNO("Failed to lock `%s'",
+                                                  w->filename);
                                ret = 0;
                        }
                } else {
                                ret = 0;
                        }
                } else {
@@ -1640,8 +1642,7 @@ void close_wim_writable(WIMStruct *w)
 {
        if (w->out_fp) {
                if (fclose(w->out_fp) != 0) {
 {
        if (w->out_fp) {
                if (fclose(w->out_fp) != 0) {
-                       WARNING("Failed to close output WIM: %s",
-                               strerror(errno));
+                       WARNING_WITH_ERRNO("Failed to close output WIM");
                }
                w->out_fp = NULL;
        }
                }
                w->out_fp = NULL;
        }
@@ -1927,8 +1928,8 @@ static int overwrite_wim_via_tmpfile(WIMStruct *w, int write_flags,
        w->fp = fopen(w->filename, "rb");
        if (w->fp == NULL) {
                ret = WIMLIB_ERR_REOPEN;
        w->fp = fopen(w->filename, "rb");
        if (w->fp == NULL) {
                ret = WIMLIB_ERR_REOPEN;
-               WARNING("Failed to re-open `%s' read-only: %s",
-                       w->filename, strerror(errno));
+               WARNING_WITH_ERRNO("Failed to re-open `%s' read-only",
+                                  w->filename);
                FREE(w->filename);
                w->filename = NULL;
        }
                FREE(w->filename);
                w->filename = NULL;
        }
@@ -1936,7 +1937,7 @@ static int overwrite_wim_via_tmpfile(WIMStruct *w, int write_flags,
 err:
        /* Remove temporary file. */
        if (unlink(tmpfile) != 0)
 err:
        /* Remove temporary file. */
        if (unlink(tmpfile) != 0)
-               WARNING("Failed to remove `%s': %s", tmpfile, strerror(errno));
+               WARNING_WITH_ERRNO("Failed to remove `%s'", tmpfile);
        return ret;
 }
 
        return ret;
 }