[PATCH 2/4] erofs-utils: silence `Unintentional integer overflow`

Gao Xiang hsiangkao at linux.alibaba.com
Tue Jul 8 12:17:20 AEST 2025


Coverity-id: 569450
Coverity-id: 569460
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/blobchunk.c | 2 +-
 lib/zmap.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index ccc77b0b..024a3927 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -150,7 +150,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,
 	else
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;
 
-	chunkblks = 1U << (inode->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
+	chunkblks = 1ULL << (inode->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
 	_48bit = inode->u.chunkformat & EROFS_CHUNK_FORMAT_48BIT;
 	for (dst = src = 0; dst < inode->extent_isize;
 	     src += sizeof(void *), dst += unit) {
diff --git a/lib/zmap.c b/lib/zmap.c
index 43e76e55..22d7a092 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -604,7 +604,7 @@ static int z_erofs_map_blocks_ext(struct erofs_inode *vi,
 		}
 		last = (lstart >= round_up(lend, 1 << vi->z_lclusterbits));
 		lend = min(lstart, lend);
-		lstart -= 1 << vi->z_lclusterbits;
+		lstart -= 1ULL << vi->z_lclusterbits;
 	} else {
 		lstart = lend;
 		for (l = 0, r = vi->z_extents; l < r; ) {
-- 
2.43.5



More information about the Linux-erofs mailing list