]> wimlib.net Git - wimlib/commitdiff
write.c: warn if WIM file cannot be truncated
authorEric Biggers <ebiggers3@gmail.com>
Sat, 6 Feb 2016 15:47:14 +0000 (09:47 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 9 Feb 2016 01:44:33 +0000 (19:44 -0600)
Somewhat pointless since this is already an error path, but this avoids
a gcc warning about ftruncate()'s return value not being used.

src/write.c

index 9f48d3f1ded5973d1a215c5cd4b23f9f391d5d12..cc569395d19c12f3f499b5a68f8523f33e5055bd 100644 (file)
@@ -3223,9 +3223,8 @@ out_truncate:
                             WIMLIB_WRITE_FLAG_UNSAFE_COMPACT))) {
                WARNING("Truncating \"%"TS"\" to its original size "
                        "(%"PRIu64" bytes)", wim->filename, old_wim_end);
                             WIMLIB_WRITE_FLAG_UNSAFE_COMPACT))) {
                WARNING("Truncating \"%"TS"\" to its original size "
                        "(%"PRIu64" bytes)", wim->filename, old_wim_end);
-               /* Return value of ftruncate() is ignored because this is
-                * already an error path.  */
-               (void)ftruncate(wim->out_fd.fd, old_wim_end);
+               if (ftruncate(wim->out_fd.fd, old_wim_end))
+                       WARNING_WITH_ERRNO("Failed to truncate WIM file!");
        }
 out_restore_hdr:
        (void)write_wim_header_flags(wim->hdr.flags, &wim->out_fd);
        }
 out_restore_hdr:
        (void)write_wim_header_flags(wim->hdr.flags, &wim->out_fd);