erofs-utils: fix invalid argument type in erofs_err()
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Fri, 30 Aug 2024 10:03:54 +0000 (18:03 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 4 Sep 2024 02:32:12 +0000 (10:32 +0800)
Fix several issues found by Coverity regarding "Invalid type in argument
for printf format specifier".

Coverity-id: 502374, 502367, 502362, 502348, 502342, 502341,
     502340, 502358
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240830100354.2093735-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fsck/main.c
lib/blobchunk.c
lib/compress.c
lib/fragments.c
lib/super.c
mkfs/main.c

index 28f1e7e6db1385b82748e1fd0756fa11959c7f4d..89d87fbb2aa7926afda496e3c2deba9071bc8958 100644 (file)
@@ -807,8 +807,8 @@ static int erofsfsck_dirent_iter(struct erofs_dir_context *ctx)
        curr_pos = prev_pos;
 
        if (prev_pos + ctx->de_namelen >= PATH_MAX) {
-               erofs_err("unable to fsck since the path is too long (%u)",
-                         curr_pos + ctx->de_namelen);
+               erofs_err("unable to fsck since the path is too long (%llu)",
+                         (curr_pos + ctx->de_namelen) | 0ULL);
                return -EOPNOTSUPP;
        }
 
index 2835755190c46e3a4b3d4b0853a95ed00b104d21..33dadd595172570811b3690be2018e572273f031 100644 (file)
@@ -95,7 +95,8 @@ static struct erofs_blobchunk *erofs_blob_getchunk(struct erofs_sb_info *sbi,
                chunk->device_id = 0;
        chunk->blkaddr = erofs_blknr(sbi, blkpos);
 
-       erofs_dbg("Writing chunk (%u bytes) to %u", chunksize, chunk->blkaddr);
+       erofs_dbg("Writing chunk (%llu bytes) to %u", chunksize | 0ULL,
+                 chunk->blkaddr);
        ret = fwrite(buf, chunksize, 1, blobfile);
        if (ret == 1) {
                padding = erofs_blkoff(sbi, chunksize);
index 8655e785be21d69ae0bc19103c6edfb3011e11de..17e7112cde760a08fae6e43828a904f43b417aba 100644 (file)
@@ -497,8 +497,8 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_compress_sctx *ctx,
        inode->fragmentoff += inode->fragment_size - newsize;
        inode->fragment_size = newsize;
 
-       erofs_dbg("Reducing fragment size to %u at %llu",
-                 inode->fragment_size, inode->fragmentoff | 0ULL);
+       erofs_dbg("Reducing fragment size to %llu at %llu",
+                 inode->fragment_size | 0ULL, inode->fragmentoff | 0ULL);
 
        /* it's the end */
        DBG_BUGON(ctx->tail - ctx->head + ctx->remaining != newsize);
index 7591718ae390ec928d4dd72479dcb77066b8a6fb..e2d3343dde91a955cf9b4dcf73d260a946af64ed 100644 (file)
@@ -138,7 +138,7 @@ static int z_erofs_fragments_dedupe_find(struct erofs_inode *inode, int fd,
        inode->fragment_size = deduped;
        inode->fragmentoff = pos;
 
-       erofs_dbg("Dedupe %u tail data at %llu", inode->fragment_size,
+       erofs_dbg("Dedupe %llu tail data at %llu", inode->fragment_size | 0ULL,
                  inode->fragmentoff | 0ULL);
 out:
        free(data);
@@ -283,8 +283,8 @@ int z_erofs_pack_file_from_fd(struct erofs_inode *inode, int fd,
                goto out;
        }
 
-       erofs_dbg("Recording %u fragment data at %lu", inode->fragment_size,
-                 inode->fragmentoff);
+       erofs_dbg("Recording %llu fragment data at %llu",
+                 inode->fragment_size | 0ULL, inode->fragmentoff | 0ULL);
 
        if (memblock)
                rc = z_erofs_fragments_dedupe_insert(memblock,
@@ -316,8 +316,8 @@ int z_erofs_pack_fragments(struct erofs_inode *inode, void *data,
        if (fwrite(data, len, 1, packedfile) != 1)
                return -EIO;
 
-       erofs_dbg("Recording %u fragment data at %lu", inode->fragment_size,
-                 inode->fragmentoff);
+       erofs_dbg("Recording %llu fragment data at %llu",
+                 inode->fragment_size | 0ULL, inode->fragmentoff | 0ULL);
 
        ret = z_erofs_fragments_dedupe_insert(data, len, inode->fragmentoff,
                                              tofcrc);
index 32e10cd9c152090c608de70e56e2d2eef97d6aa2..d4cea50fe63c81f448479e664dc1ff227b38c869 100644 (file)
@@ -213,7 +213,8 @@ struct erofs_buffer_head *erofs_reserve_sb(struct erofs_bufmgr *bmgr)
 
        bh = erofs_balloc(bmgr, META, 0, 0, 0);
        if (IS_ERR(bh)) {
-               erofs_err("failed to allocate super: %s", PTR_ERR(bh));
+               erofs_err("failed to allocate super: %s",
+                         erofs_strerror(PTR_ERR(bh)));
                return bh;
        }
        bh->op = &erofs_skip_write_bhops;
index 5cc2778aa368a4acbabe315adec564c0f5ea8671..5c8b5e4f394e9651578f027d81090fddd0c8a803 100644 (file)
@@ -274,7 +274,7 @@ static int erofs_mkfs_feat_set_fragments(bool en, const char *val,
                u64 i = strtoull(val, &endptr, 0);
 
                if (endptr - val != vallen) {
-                       erofs_err("invalid pcluster size %s for the packed file %s", val);
+                       erofs_err("invalid pcluster size %s for the packed file", val);
                        return -EINVAL;
                }
                pclustersize_packed = i;