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 9f48d3f..cc56939 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);
-               /* 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);