diff options
author | Ruediger Meier | 2016-02-22 11:58:05 +0100 |
---|---|---|
committer | Ruediger Meier | 2016-03-07 23:16:04 +0100 |
commit | fdbd7bb94051bce49a40b0e055bfa21755de3b1c (patch) | |
tree | b4525048d811b8a7bf1d6574922995fa25fb8a9f /disk-utils | |
parent | wipefs, sfdisk: include libgen.h for basename(3p) (diff) | |
download | kernel-qcow2-util-linux-fdbd7bb94051bce49a40b0e055bfa21755de3b1c.tar.gz kernel-qcow2-util-linux-fdbd7bb94051bce49a40b0e055bfa21755de3b1c.tar.xz kernel-qcow2-util-linux-fdbd7bb94051bce49a40b0e055bfa21755de3b1c.zip |
misc: again fixing many printf format strings
This is again a huge patch regarding printf format strings to
fix compiler warnings seen on clang/OSX.
I'm trying to follow these rules strictly:
#type #format #cast
uintmax_t %ju -
intmax_t %jd -
uint64_t PRIu64 -
int64_t PRId64 -
size_t %zu -
ssize_t %zd -
ino_t %ju (uintmax_t)
off_t %jd (intmax_t)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/fdisk.c | 25 | ||||
-rw-r--r-- | disk-utils/fsck.minix.c | 5 | ||||
-rw-r--r-- | disk-utils/mkfs.minix.c | 5 | ||||
-rw-r--r-- | disk-utils/mkswap.c | 4 | ||||
-rw-r--r-- | disk-utils/sfdisk.c | 17 |
5 files changed, 33 insertions, 23 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 304eccc1b..3aa915b2c 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -194,7 +194,7 @@ static int ask_number(struct fdisk_context *cxt, assert(q); DBG(ASK, ul_debug("asking for number " - "['%s', <%ju,%ju>, default=%ju, range: %s]", + "['%s', <%"PRIu64",%"PRIu64">, default=%"PRIu64", range: %s]", q, low, high, dflt, range)); if (range && dflt >= low && dflt <= high) { @@ -202,7 +202,7 @@ static int ask_number(struct fdisk_context *cxt, snprintf(prompt, sizeof(prompt), _("%s (%s, default %c): "), q, range, tochar(dflt)); else - snprintf(prompt, sizeof(prompt), _("%s (%s, default %ju): "), + snprintf(prompt, sizeof(prompt), _("%s (%s, default %"PRIu64"): "), q, range, dflt); } else if (dflt >= low && dflt <= high) { @@ -210,13 +210,14 @@ static int ask_number(struct fdisk_context *cxt, snprintf(prompt, sizeof(prompt), _("%s (%c-%c, default %c): "), q, tochar(low), tochar(high), tochar(dflt)); else - snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju, default %ju): "), + snprintf(prompt, sizeof(prompt), + _("%s (%"PRIu64"-%"PRIu64", default %"PRIu64"): "), q, low, high, dflt); } else if (inchar) snprintf(prompt, sizeof(prompt), _("%s (%c-%c): "), q, tochar(low), tochar(high)); else - snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju): "), + snprintf(prompt, sizeof(prompt), _("%s (%"PRIu64"-%"PRIu64"): "), q, low, high); do { @@ -264,15 +265,19 @@ static int ask_offset(struct fdisk_context *cxt, assert(q); - DBG(ASK, ul_debug("asking for offset ['%s', <%ju,%ju>, base=%ju, default=%ju, range: %s]", + DBG(ASK, ul_debug("asking for offset ['%s', <%"PRIu64",%"PRIu64">, base=%"PRIu64", default=%"PRIu64", range: %s]", q, low, high, base, dflt, range)); if (range && dflt >= low && dflt <= high) - snprintf(prompt, sizeof(prompt), _("%s (%s, default %ju): "), q, range, dflt); + snprintf(prompt, sizeof(prompt), _("%s (%s, default %"PRIu64"): "), + q, range, dflt); else if (dflt >= low && dflt <= high) - snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju, default %ju): "), q, low, high, dflt); + snprintf(prompt, sizeof(prompt), + _("%s (%"PRIu64"-%"PRIu64", default %"PRIu64"): "), + q, low, high, dflt); else - snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju): "), q, low, high); + snprintf(prompt, sizeof(prompt), _("%s (%"PRIu64"-%"PRIu64"): "), + q, low, high); do { uintmax_t num = 0; @@ -629,7 +634,7 @@ static void dump_buffer(off_t base, unsigned char *buf, size_t sz, int all) if (l == 0) { if (all == 0 && !next) next = skip_empty(buf, i, sz); - printf("%08jx ", base + i); + printf("%08jx ", (intmax_t)base + i); } printf(" %02x", buf[i]); if (l == 7) /* words separator */ @@ -653,7 +658,7 @@ static void dump_blkdev(struct fdisk_context *cxt, const char *name, { int fd = fdisk_get_devfd(cxt); - fdisk_info(cxt, _("\n%s: offset = %ju, size = %zu bytes."), + fdisk_info(cxt, _("\n%s: offset = %"PRIu64", size = %zu bytes."), name, offset, size); assert(fd >= 0); diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index a040cf51a..aa64569ff 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -626,7 +626,8 @@ read_tables(void) { if (show) { printf(_("%ld inodes\n"), inodes); printf(_("%ld blocks\n"), zones); - printf(_("Firstdatazone=%jd (%jd)\n"), first_zone, norm_first_zone); + printf(_("Firstdatazone=%jd (%jd)\n"), + (intmax_t)first_zone, (intmax_t)norm_first_zone); printf(_("Zonesize=%d\n"), MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n"), get_max_size()); if (fs_version < 3) @@ -1053,7 +1054,7 @@ check_file2(struct minix2_inode *dir, unsigned int offset) { name_depth++; if (list) { if (verbose) - printf("%6ju %07o %3d ", ino, inode->i_mode, + printf("%6ju %07o %3d ", (uintmax_t)ino, inode->i_mode, inode->i_nlinks); get_current_name(); printf("%s", current_name); diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 24e618871..a4118f175 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -543,7 +543,7 @@ static void setup_tables(const struct fs_control *ctl) { errx(MKFS_EX_ERROR, _("First data block at %jd, which is too far (max %d).\n" "Try specifying fewer inodes by passing --inodes <num>"), - first_zone_data(), + (intmax_t)first_zone_data(), MINIX_MAX_INODES); imaps = get_nimaps(); zmaps = get_nzmaps(); @@ -563,7 +563,8 @@ static void setup_tables(const struct fs_control *ctl) { printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes); printf(P_("%lu block\n", "%lu blocks\n", zones), zones); - printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data()); + printf(_("Firstdatazone=%jd (%jd)\n"), + (intmax_t)get_first_zone(), (intmax_t)first_zone_data()); printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n\n"),get_max_size()); } diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index ae02de569..52ee8c65d 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -443,7 +443,7 @@ int main(int argc, char **argv) else if (ctl.npages > sz && !ctl.force) errx(EXIT_FAILURE, _("error: " - "size %llu KiB is larger than device size %ju KiB"), + "size %llu KiB is larger than device size %"PRIu64" KiB"), ctl.npages * (ctl.pagesize / 1024), sz * (ctl.pagesize / 1024)); if (ctl.npages < MIN_GOODPAGES) @@ -489,7 +489,7 @@ int main(int argc, char **argv) sz = (ctl.npages - ctl.nbadpages - 1) * ctl.pagesize; strsz = size_to_human_string(SIZE_SUFFIX_SPACE | SIZE_SUFFIX_3LETTER, sz); - printf(_("Setting up swapspace version %d, size = %s (%ju bytes)\n"), + printf(_("Setting up swapspace version %d, size = %s (%"PRIu64" bytes)\n"), version, strsz, sz); free(strsz); diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 14c7cc089..3dfdd9e9a 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -278,7 +278,7 @@ static void backup_sectors(struct sfdisk *sf, devfd = fdisk_get_devfd(sf->cxt); assert(devfd >= 0); - xasprintf(&fname, "%s0x%08jx.bak", tpl, offset); + xasprintf(&fname, "%s0x%08"PRIx64".bak", tpl, offset); fd = open(fname, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); if (fd < 0) @@ -421,7 +421,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa step--; step_bytes = step * ss; - DBG(MISC, ul_debug(" step: %ju (%ju bytes)", step, step_bytes)); + DBG(MISC, ul_debug(" step: %ju (%zu bytes)", (uintmax_t)step, step_bytes)); #if defined(POSIX_FADV_SEQUENTIAL) && defined(HAVE_POSIX_FADVISE) if (!backward) @@ -437,7 +437,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa color_disable(); fdisk_info(sf->cxt, _(" typescript file: %s"), typescript); printf(_(" old start: %ju, new start: %ju (move %ju sectors)\n"), - (uintmax_t) from, (uintmax_t) to, nsectors); + (uintmax_t) from, (uintmax_t) to, (uintmax_t) nsectors); fflush(stdout); } @@ -459,12 +459,15 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa fprintf(f, "# Disk: %s\n", devname); fprintf(f, "# Partition: %zu\n", partno + 1); fprintf(f, "# Operation: move data\n"); - fprintf(f, "# Original start offset (sectors/bytes): %ju/%ju\n", from, from * ss); - fprintf(f, "# New start offset (sectors/bytes): %ju/%ju\n", to, to * ss); - fprintf(f, "# Area size (sectors/bytes): %ju/%ju\n", nsectors, nsectors * ss); + fprintf(f, "# Original start offset (sectors/bytes): %ju/%ju\n", + (uintmax_t)from, (uintmax_t)from * ss); + fprintf(f, "# New start offset (sectors/bytes): %ju/%ju\n", + (uintmax_t)to, (uintmax_t)to * ss); + fprintf(f, "# Area size (sectors/bytes): %ju/%ju\n", + (uintmax_t)nsectors, (uintmax_t)nsectors * ss); fprintf(f, "# Sector size: %zu\n", ss); fprintf(f, "# Step size (in bytes): %zu\n", step_bytes); - fprintf(f, "# Steps: %zu\n", nsectors / step); + fprintf(f, "# Steps: %ju\n", (uintmax_t)(nsectors / step)); fprintf(f, "#\n"); fprintf(f, "# <step>: <from> <to> (step offsets in bytes)\n"); |