use proper format specifiers

This commit is contained in:
Thomas Lindner 2023-02-12 18:40:42 +01:00
parent 1325027567
commit 833a6c5a55

View file

@ -26,7 +26,7 @@
#include <err.h> #include <err.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -77,7 +77,7 @@ int main(int argc, char **argv) {
usage(); usage();
} }
mode |= MODE_INODE; mode |= MODE_INODE;
inode = strtonum(optarg, 2, UINT_MAX, &errstr); inode = strtonum(optarg, 2, UINT32_MAX, &errstr);
if (errstr) { if (errstr) {
errx(1, "Invalid inode %s: %s", optarg, errstr); errx(1, "Invalid inode %s: %s", optarg, errstr);
} }
@ -225,9 +225,10 @@ void dump_inode(ino_t inum, union dinode *dp) {
default: default:
type = 'u'; type = 'u';
} }
printf("inode:%llu type:%c mode:%o nlink:%u uid:%u gid:%u size:%llu " printf("inode:%" PRIu32 " type:%c mode:%" PRIo16 " nlink:%" PRId16
"atime:%llu mtime:%llu ctime:%llu \n", " uid:%" PRIu32 " gid:%" PRIu32 " size:%" PRIu64 " atime:%" PRId64
inum, type, DIP(dp, di_mode) & ~IFMT, DIP(dp, di_nlink), " mtime:%" PRId64 " ctime:%" PRId64 "\n",
(uint32_t)inum, type, DIP(dp, di_mode) & ~IFMT, DIP(dp, di_nlink),
DIP(dp, di_uid), DIP(dp, di_gid), DIP(dp, di_size), DIP(dp, di_atime), DIP(dp, di_uid), DIP(dp, di_gid), DIP(dp, di_size), DIP(dp, di_atime),
DIP(dp, di_mtime), DIP(dp, di_ctime)); DIP(dp, di_mtime), DIP(dp, di_ctime));
} }
@ -318,7 +319,7 @@ void dump_file_indirect(union dinode *dp, void *indirblock, int level,
} }
} }
free(datablock); free(datablock);
fprintf(stderr, "\r%llu/%llu", DIP(dp, di_size) - *filesize, fprintf(stderr, "\r%" PRIu64 "/%" PRIu64, DIP(dp, di_size) - *filesize,
DIP(dp, di_size)); DIP(dp, di_size));
} }