This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch main in repository gfs2-utils.
commit d028863b8bd54c19f0c87556a7e5cf17d2a583c3 Author: Andrew Price anprice@redhat.com AuthorDate: Thu Jan 6 10:53:49 2022 +0000
gfs2_edit: Use PRIu64 instead of casting uint64_t to unsigned long long
Also fix up some places where the wrong type is used for block addresses.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/edit/extended.c | 6 +++--- gfs2/edit/hexedit.c | 38 +++++++++++++++++--------------------- gfs2/edit/journal.c | 26 ++++++++++---------------- gfs2/edit/journal.h | 2 +- gfs2/edit/savemeta.c | 4 ++-- 5 files changed, 33 insertions(+), 43 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c index c2865829..8d914681 100644 --- a/gfs2/edit/extended.c +++ b/gfs2/edit/extended.c @@ -181,9 +181,9 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level, if (edit_row[dmode] >= 0 && line - start_line == edit_row[dmode] - start_row[dmode]) { - sprintf(estring, "%llx", - (unsigned long long)ind->ii[print_entry_ndx].block); - strcpy(edit_fmt, "%llx"); + sprintf(estring, "%"PRIx64, + ind->ii[print_entry_ndx].block); + strcpy(edit_fmt, "%"PRIx64); edit_size[dmode] = strlen(estring); COLORS_NORMAL; } diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index f665d013..0662fc3f 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1011,10 +1011,9 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref, ioctl(sbd.device_fd, BLKFLSBUF, 0); if (!(bh = bread(&sbd, blk))) { fprintf(stderr, "read error: %s from %s:%d: " - "offset %lld (0x%llx)\n", + "offset %"PRIu64" (0x%"PRIx64")\n", strerror(errno), __FUNCTION__, __LINE__, - (unsigned long long)dev_offset, - (unsigned long long)dev_offset); + dev_offset, dev_offset); exit(-1); } } @@ -1173,9 +1172,9 @@ static uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int p blk = 0; if (print) { if (dmode == HEX_MODE) - printf("0x%llx\n", (unsigned long long)blk); + printf("0x%"PRIx64"\n", blk); else - printf("%llu\n", (unsigned long long)blk); + printf("%"PRIu64"\n", blk); } gfs2_rgrp_free(&sbd, &sbd.rgtree); if (print) @@ -1260,9 +1259,9 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri blk = 0; if (print) { if (dmode == HEX_MODE) - printf("0x%llx\n", (unsigned long long)blk); + printf("0x%"PRIx64"\n", blk); else - printf("%llu\n", (unsigned long long)blk); + printf("%"PRIu64"\n", blk); } gfs2_rgrp_free(&sbd, &sbd.rgtree); if (print) @@ -1310,7 +1309,7 @@ static uint64_t find_metablockoftype(const char *strtype, int print) /* ------------------------------------------------------------------------ */ uint64_t check_keywords(const char *kword) { - unsigned long long blk = 0; + uint64_t blk = 0;
if (!strcmp(kword, "sb") ||!strcmp(kword, "superblock")) blk = 0x10 * (4096 / sbd.sd_bsize); /* superblock */ @@ -1367,9 +1366,9 @@ uint64_t check_keywords(const char *kword) } else if (kword[0]=='/') /* search */ blk = find_metablockoftype(&kword[1], 0); else if (kword[0]=='0' && kword[1]=='x') /* hex addr */ - sscanf(kword, "%llx", &blk);/* retrieve in hex */ + sscanf(kword, "%"SCNx64, &blk);/* retrieve in hex */ else - sscanf(kword, "%llu", &blk); /* retrieve decimal */ + sscanf(kword, "%"SCNu64, &blk); /* retrieve decimal */
return blk; } @@ -1474,11 +1473,10 @@ static void hex_edit(int *exitch) if (pwrite(sbd.device_fd, bh->b_data, sbd.sd_bsize, dev_offset) != sbd.sd_bsize) { fprintf(stderr, "write error: %s from %s:%d: " - "offset %lld (0x%llx)\n", + "offset %"PRIu64" (0x%"PRIx64")\n", strerror(errno), __FUNCTION__, __LINE__, - (unsigned long long)dev_offset, - (unsigned long long)dev_offset); + dev_offset, dev_offset); exit(-1); } fsync(sbd.device_fd); @@ -1649,9 +1647,9 @@ static void find_print_block_rg(int bitmap)
} if (dmode == HEX_MODE) - printf("0x%llx\n",(unsigned long long)rgblock); + printf("0x%"PRIx64"\n", rgblock); else - printf("%llu\n", (unsigned long long)rgblock); + printf("%"PRIu64"\n", rgblock); } else { printf("-1 (block invalid or part of an rgrp).\n"); } @@ -2383,13 +2381,13 @@ static void process_parameters(int argc, char *argv[], int pass)
if (!strncmp(argv[i], "journal", 7) && isdigit(argv[i][7]) && strcmp(argv[i+1], "field")) { - int blk = 0; + uint64_t blk = 0;
if (i < argc - 1 && isdigit(argv[i + 1][0])) { if (argv[i + 1][0]=='0' && argv[i + 1][1]=='x') - sscanf(argv[i + 1], "%x", &blk); + sscanf(argv[i + 1], "%"SCNx64, &blk); else - blk = atoi(argv[i + 1]); + sscanf(argv[i + 1], "%"SCNu64, &blk); } dump_journal(argv[i], blk); continue; @@ -2404,9 +2402,7 @@ static void process_parameters(int argc, char *argv[], int pass) else if (!strcmp(argv[i], "identify")) identify = TRUE; else if (!strcmp(argv[i], "size")) { - printf("Device size: %llu (0x%llx)\n", - (unsigned long long)max_block, - (unsigned long long)max_block); + printf("Device size: %"PRIu64" blocks\n", max_block); exit(EXIT_SUCCESS); } else if (!strcmp(argv[i], "rgcount")) rgcount(); diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c index ea32f9a2..11f9e032 100644 --- a/gfs2/edit/journal.c +++ b/gfs2/edit/journal.c @@ -237,8 +237,7 @@ static int print_ld_blks(const __be64 *b, const char *end, int start_line, (*bblk_off)++; if (tblk && (be64_to_cpu(*b) == tblk)) { found_tblk = 1; - print_gfs2("<-------------------------0x%llx ", - (unsigned long long)tblk); + print_gfs2("<-------------------------0x%"PRIx64" ", tblk); eol(18 * (bcount % 4) + 1); print_gfs2(" "); } @@ -269,15 +268,12 @@ static int print_ld_blks(const __be64 *b, const char *end, int start_line, exit(1); } rgd->bits[bmap].bi_data = save_ptr; - print_gfs2("bit for blk 0x%llx is %d " - "(%s)", - (unsigned long long)tblk, - type, + print_gfs2("bit for blk 0x%"PRIx64" is %d (%s)", + tblk, type, allocdesc[sbd.gfs1][type]); } else { - print_gfs2("bitmap for blk 0x%llx " - "was revoked", - (unsigned long long)tblk); + print_gfs2("bitmap for blk 0x%"PRIx64" was revoked", + tblk); } eol(18 * (bcount % 4) + 1); print_gfs2(" "); @@ -503,7 +499,7 @@ static void display_log_header(void *buf, uint64_t *highest_seq, uint64_t abs_bl * block, (2) metadata in the journal that references the block, or (3) * rgrp bitmaps that reference that block's allocation bit status. */ -void dump_journal(const char *journal, int tblk) +void dump_journal(const char *journal, uint64_t tblk) { const struct lgfs2_metadata *mtype; struct gfs2_buffer_head *j_bh = NULL; @@ -526,7 +522,7 @@ void dump_journal(const char *journal, int tblk) print_gfs2("Dumping journal #%d.", journal_num); if (tblk) { dmode = HEX_MODE; - print_gfs2(" Tracing block 0x%llx", (unsigned long long)tblk); + print_gfs2(" Tracing block 0x%"PRIx64, tblk); } eol(0); jblock = find_journal_block(journal, &j_size); @@ -552,7 +548,7 @@ void dump_journal(const char *journal, int tblk)
rgd = gfs2_blk2rgrpd(&sbd, tblk); if (!rgd) { - print_gfs2("Can't locate the rgrp for block 0x%x", + print_gfs2("Can't locate the rgrp for block 0x%"PRIx64, tblk); eol(0); } else { @@ -575,10 +571,8 @@ void dump_journal(const char *journal, int tblk)
wrappt = find_wrap_pt(j_inode, jbuf, jblock, j_size); wp = wrappt / (sbd.gfs1 ? 1 : sbd.sd_bsize); - print_gfs2("Starting at journal wrap block: 0x%llx " - "(j + 0x%llx)", - (unsigned long long)jblock + wp, - (unsigned long long)wp); + print_gfs2("Starting at journal wrap block: 0x%"PRIx64" (j + 0x%"PRIx64")", + jblock + wp, wp); eol(0); }
diff --git a/gfs2/edit/journal.h b/gfs2/edit/journal.h index 1e5968b6..213c1f69 100644 --- a/gfs2/edit/journal.h +++ b/gfs2/edit/journal.h @@ -1,7 +1,7 @@ #ifndef __JOURNAL_DOT_H__ #define __JOURNAL_DOT_H__
-extern void dump_journal(const char *journal, int tblk); +extern void dump_journal(const char *journal, uint64_t tblk); extern uint64_t find_journal_block(const char *journal, uint64_t *j_size);
#endif diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 0b0b7963..2d53ff10 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -1131,8 +1131,8 @@ void savemeta(char *out_fn, int saveoption, int gziplevel) blks_saved = 0; if (sbd.gfs1) sbd.sd_bsize = sbd.sd_bsize; - printf("There are %llu blocks of %u bytes in the filesystem.\n", - (unsigned long long)sbd.fssize, sbd.sd_bsize); + printf("There are %"PRIu64" blocks of %u bytes in the filesystem.\n", + sbd.fssize, sbd.sd_bsize);
printf("Filesystem size: %.2fGB\n", (sbd.fssize * sbd.sd_bsize) / ((float)(1 << 30))); get_journal_inode_blocks();
cluster-commits@lists.fedorahosted.org