From 4d0a62805708a6d3fe21f615ccfaa3964adbf259 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 25 Jun 2021 14:30:31 +0200 Subject: Fix format string type/signedness mismatch issues Signed-off-by: David Oberhollenzer --- bin/rdsquashfs/describe.c | 5 +++-- bin/rdsquashfs/stat.c | 7 ++++--- extras/browse.c | 12 ++++++++---- extras/list_files.c | 6 ++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/bin/rdsquashfs/describe.c b/bin/rdsquashfs/describe.c index 5107f95..e0e22bc 100644 --- a/bin/rdsquashfs/describe.c +++ b/bin/rdsquashfs/describe.c @@ -53,7 +53,8 @@ static int print_name(const sqfs_tree_node_t *n, bool dont_escape) static void print_perm(const sqfs_tree_node_t *n) { - printf(" 0%o %d %d", n->inode->base.mode & (~S_IFMT), n->uid, n->gid); + printf(" 0%o %u %u", (unsigned int)n->inode->base.mode & (~S_IFMT), + n->uid, n->gid); } static int print_simple(const char *type, const sqfs_tree_node_t *n, @@ -112,7 +113,7 @@ int describe_tree(const sqfs_tree_node_t *root, const char *unpack_root) devno = root->inode->data.dev.devno; } - sprintf(buffer, "%c %d %d", + sprintf(buffer, "%c %u %u", S_ISCHR(root->inode->base.mode) ? 'c' : 'b', major(devno), minor(devno)); return print_simple("nod", root, buffer); diff --git a/bin/rdsquashfs/stat.c b/bin/rdsquashfs/stat.c index 642aae9..ae6e10b 100644 --- a/bin/rdsquashfs/stat.c +++ b/bin/rdsquashfs/stat.c @@ -99,7 +99,8 @@ int stat_file(const sqfs_tree_node_t *node) printf("Name: %s\n", (const char *)node->name); printf("Inode type: %s\n", type == NULL ? "UNKNOWN" : type); printf("Inode number: %u\n", inode->base.inode_number); - printf("Access: 0%o\n", inode->base.mode & ~SQFS_INODE_MODE_MASK); + printf("Access: 0%o\n", + (unsigned int)inode->base.mode & ~SQFS_INODE_MODE_MASK); printf("UID: %u (index = %u)\n", node->uid, inode->base.uid_idx); printf("GID: %u (index = %u)\n", node->gid, inode->base.gid_idx); printf("Last modified: %s (%u)\n", buffer, inode->base.mod_time); @@ -111,7 +112,7 @@ int stat_file(const sqfs_tree_node_t *node) printf("Xattr index: 0x%X\n", xattr_idx); if (link_target != NULL) - printf("Link target: %.*s\n", link_size, link_target); + printf("Link target: %.*s\n", (int)link_size, link_target); if (have_devno) { printf("Device number: %u:%u (%u)\n", @@ -171,7 +172,7 @@ int stat_file(const sqfs_tree_node_t *node) } printf("\t'%.*s' -> block %u, header offset %u\n", - idx->size + 1, idx->name, + (int)(idx->size + 1), idx->name, idx->start_block, idx->index); sqfs_free(idx); diff --git a/extras/browse.c b/extras/browse.c index d78ac5a..6d03312 100644 --- a/extras/browse.c +++ b/extras/browse.c @@ -267,7 +267,8 @@ static void stat_cmd(const char *filename) printf("Inode number: %u\n", inode->base.inode_number); mode_to_str(inode->base.mode & ~SQFS_INODE_MODE_MASK, buffer); - printf("Access: 0%o/%s\n", inode->base.mode & ~SQFS_INODE_MODE_MASK, + printf("Access: 0%o/%s\n", + (unsigned int)inode->base.mode & ~SQFS_INODE_MODE_MASK, buffer); /* resolve and print UID/GID */ @@ -317,13 +318,15 @@ static void stat_cmd(const char *filename) break; case SQFS_INODE_SLINK: printf("Hard link count: %u\n", inode->data.slink.nlink); - printf("Link target: %.*s\n", inode->data.slink.target_size, + printf("Link target: %.*s\n", + (int)inode->data.slink.target_size, (const char *)inode->extra); break; case SQFS_INODE_EXT_SLINK: printf("Hard link count: %u\n", inode->data.slink_ext.nlink); printf("Xattr index: 0x%X\n", inode->data.slink_ext.xattr_idx); - printf("Link target: %.*s\n", inode->data.slink_ext.target_size, + printf("Link target: %.*s\n", + (int)inode->data.slink_ext.target_size, (const char *)inode->extra); break; case SQFS_INODE_FILE: @@ -398,7 +401,8 @@ static void stat_cmd(const char *filename) printf("\tIndex: %u\n", idx->index); printf("\tStart block: %u\n", idx->start_block); printf("\tSize: %u\n", idx->size + 1); - printf("\tEntry: %.*s\n\n", idx->size + 1, idx->name); + printf("\tEntry: %.*s\n\n", + (int)(idx->size + 1), idx->name); sqfs_free(idx); } diff --git a/extras/list_files.c b/extras/list_files.c index 434601a..5f0742d 100644 --- a/extras/list_files.c +++ b/extras/list_files.c @@ -33,10 +33,12 @@ static void write_tree_dfs(const sqfs_tree_node_t *n) fputs((const char *)n->name, stdout); if (n->inode->base.type == SQFS_INODE_SLINK) { - printf(" ⭢ %.*s", n->inode->data.slink.target_size, + printf(" ⭢ %.*s", + (int)n->inode->data.slink.target_size, (const char *)n->inode->extra); } else if (n->inode->base.type == SQFS_INODE_EXT_SLINK) { - printf(" ⭢ %.*s", n->inode->data.slink_ext.target_size, + printf(" ⭢ %.*s", + (int)n->inode->data.slink_ext.target_size, (const char *)n->inode->extra); } -- cgit v1.2.3