Fix various -Wformat problems.

Updating gnulib has caused -Wformat-signedness to be enabled.  This
has revealed many problems in C format strings.  The fixes here fall
into the following main categories:

 - Using %d with an unsigned parameter.

 - %x and %o expect an unsigned argument.

 - uid_t and gid_t are unsigned on Linux.  The safe way to print these
   is to cast them to uintmax_t and then print them using the %ju
   modifier (see http://stackoverflow.com/a/1401581).

 - Using %d to print an enum.  Since enums may be either char or int,
   I fixed this by casting the enum to int.

 - strtol_error & lzma_ret are both unsigned types.
This commit is contained in:
Richard W.M. Jones
2015-07-02 15:36:04 +01:00
parent b263035c1a
commit ccdbbc7fe4
26 changed files with 84 additions and 70 deletions

View File

@@ -172,7 +172,7 @@ do_zero_device (const char *device)
if (!is_zero (buf, sizeof buf)) {
r = pwrite (fd, zero_buf, n, pos);
if (r == -1) {
reply_with_perror ("pwrite: %s (with %" PRId64 " bytes left to write)",
reply_with_perror ("pwrite: %s (with %" PRIu64 " bytes left to write)",
device, size);
close (fd);
return -1;