[PATCH] erofs-utils: fix false-positive errors on gcc 4.8.5

Gao Xiang hsiangkao at linux.alibaba.com
Tue May 28 16:43:13 AEST 2024


Just old compiler bugs.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/data.c      | 2 +-
 lib/dedupe.c    | 2 +-
 lib/fragments.c | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/data.c b/lib/data.c
index a87053f..c139e0c 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -420,7 +420,7 @@ static void *erofs_read_metadata_bdi(struct erofs_sb_info *sbi,
 	ret = blk_read(sbi, 0, data, erofs_blknr(sbi, *offset), 1);
 	if (ret)
 		return ERR_PTR(ret);
-	len = le16_to_cpu(*(__le16 *)&data[erofs_blkoff(sbi, *offset)]);
+	len = le16_to_cpu(*(__le16 *)(data + erofs_blkoff(sbi, *offset)));
 	if (!len)
 		return ERR_PTR(-EFSCORRUPTED);
 
diff --git a/lib/dedupe.c b/lib/dedupe.c
index aaaccb5..e475635 100644
--- a/lib/dedupe.c
+++ b/lib/dedupe.c
@@ -99,7 +99,7 @@ int z_erofs_dedupe_match(struct z_erofs_dedupe_ctx *ctx)
 		struct z_erofs_dedupe_item *e;
 
 		unsigned int extra = 0;
-		u64 xxh64_csum;
+		u64 xxh64_csum = 0;
 
 		if (initial) {
 			/* initial try */
diff --git a/lib/fragments.c b/lib/fragments.c
index d4f6be1..f4c9bd7 100644
--- a/lib/fragments.c
+++ b/lib/fragments.c
@@ -289,6 +289,8 @@ int z_erofs_pack_file_from_fd(struct erofs_inode *inode, int fd,
 	if (memblock)
 		rc = z_erofs_fragments_dedupe_insert(memblock,
 			inode->fragment_size, inode->fragmentoff, tofcrc);
+	else
+		rc = 0;
 out:
 	if (memblock)
 		munmap(memblock, inode->i_size);
-- 
2.39.3



More information about the Linux-erofs mailing list