All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: fix incorrect field conversions
@ 2026-08-27  2:06 Yifan Zhao
  2026-08-28  8:29 ` [PATCH v2] " Yifan Zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Yifan Zhao @ 2026-08-27  2:06 UTC (permalink / raw)
  To: linux-erofs, xiang; +Cc: Yifan Zhao

Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yifan Zhao <stopire@gmail.com>
---
 dump/main.c    | 4 ++--
 lib/compress.c | 4 ++--
 lib/gzran.c    | 4 ++--
 lib/inode.c    | 2 +-
 lib/namei.c    | 2 +-
 lib/super.c    | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index 9eebcb8..28f104b 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -694,7 +694,7 @@ static void erofsdump_show_superblock(void)
 	for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
 		if (!feature_lists[i].compat)
 			continue;
-		if (le32_to_cpu(g_sbi.feature_compat) & feature_lists[i].flag) {
+		if (g_sbi.feature_compat & feature_lists[i].flag) {
 			fprintf(stdout, "%s ", feature_lists[i].name);
 			if (feature_lists[i].lkver > minkver)
 				minkver = feature_lists[i].lkver;
@@ -704,7 +704,7 @@ static void erofsdump_show_superblock(void)
 	for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
 		if (feature_lists[i].compat)
 			continue;
-		if (le32_to_cpu(g_sbi.feature_incompat) & feature_lists[i].flag) {
+		if (g_sbi.feature_incompat & feature_lists[i].flag) {
 			fprintf(stdout, "%s ", feature_lists[i].name);
 			if (feature_lists[i].lkver > minkver)
 				minkver = feature_lists[i].lkver;
diff --git a/lib/compress.c b/lib/compress.c
index 9262afa..9bbb127 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -2153,9 +2153,9 @@ static int z_erofs_build_compr_cfgs(struct erofs_importer *im,
 		} __packed zalg = {
 			.size = cpu_to_le16(sizeof(struct z_erofs_deflate_cfgs)),
 			.z = {
-				.windowbits = cpu_to_le32(ilog2(
+				.windowbits = ilog2(
 					max_dict_size
-						[Z_EROFS_COMPRESSION_DEFLATE])),
+						[Z_EROFS_COMPRESSION_DEFLATE]),
 			}
 		};
 
diff --git a/lib/gzran.c b/lib/gzran.c
index 3973c1f..a75756c 100644
--- a/lib/gzran.c
+++ b/lib/gzran.c
@@ -208,7 +208,7 @@ struct erofs_gzran_iostream {
 	struct erofs_vfile *vin;
 	struct erofs_gzran_cutpoint *cp;
 	u32 entries;
-	u32 span_size;
+	u64 span_size;
 };
 
 static void erofs_gzran_ios_vfclose(struct erofs_vfile *vf)
@@ -346,7 +346,7 @@ struct erofs_vfile *erofs_gzran_zinfo_open(struct erofs_vfile *vin,
 	ios = (struct erofs_gzran_iostream *)vf->payload;
 	h = zinfo_buf;
 	ios->entries = le32_to_cpu(h->have);
-	ios->span_size = le32_to_cpu(h->span_size);
+	ios->span_size = le64_to_cpu(h->span_size);
 
 	v2_size = sizeof(*c) * ios->entries + sizeof(*h);
 	if (!len || v2_size == len) {
diff --git a/lib/inode.c b/lib/inode.c
index 0547b60..a69439c 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -851,7 +851,7 @@ int erofs_iflush(struct erofs_inode *inode)
 
 		u.dic.i_uid = cpu_to_le16((u16)inode->i_uid);
 		u.dic.i_gid = cpu_to_le16((u16)inode->i_gid);
-		u.dic.i_mtime = cpu_to_le64(inode->i_mtime - sbi->epoch);
+		u.dic.i_mtime = cpu_to_le32(inode->i_mtime - sbi->epoch);
 		u.dic.i_u = u1;
 
 		if (nlink_1) {
diff --git a/lib/namei.c b/lib/namei.c
index f19e4b1..9d04693 100644
--- a/lib/namei.c
+++ b/lib/namei.c
@@ -96,7 +96,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 		vi->i_nlink = le32_to_cpu(die->i_nlink);
 
 		vi->i_mtime = le64_to_cpu(die->i_mtime);
-		vi->i_mtime_nsec = le64_to_cpu(die->i_mtime_nsec);
+		vi->i_mtime_nsec = le32_to_cpu(die->i_mtime_nsec);
 		vi->i_size = le64_to_cpu(die->i_size);
 		break;
 	case EROFS_INODE_LAYOUT_COMPACT:
diff --git a/lib/super.c b/lib/super.c
index d138f84..e263f65 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -212,7 +212,7 @@ int erofs_writesb(struct erofs_sb_info *sbi)
 		.rb.rootnid_2b  = cpu_to_le16(sbi->root_nid),
 		.inos      = cpu_to_le64(sbi->inos),
 		.epoch     = cpu_to_le64(sbi->epoch),
-		.build_time = cpu_to_le64(sbi->build_time),
+		.build_time = cpu_to_le32(sbi->build_time),
 		.fixed_nsec = cpu_to_le32(sbi->fixed_nsec),
 		.meta_blkaddr  = cpu_to_le32(sbi->meta_blkaddr),
 		.xattr_blkaddr = cpu_to_le32(sbi->xattr_blkaddr),
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v2] erofs-utils: fix incorrect field conversions
  2026-08-27  2:06 [PATCH] erofs-utils: fix incorrect field conversions Yifan Zhao
@ 2026-08-28  8:29 ` Yifan Zhao
  0 siblings, 0 replies; 2+ messages in thread
From: Yifan Zhao @ 2026-08-28  8:29 UTC (permalink / raw)
  To: linux-erofs, xiang; +Cc: stopire

Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yifan Zhao <stopire@gmail.com>
Link: https://patch.msgid.link/20260827020629.1305900-1-stopire@gmail.com
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
Changes since v1:
- v2 only adds the missing cpu_to_le16() conversion for the 16-bit
  startblk_hi field in lib/blobchunk.c.

 dump/main.c     | 4 ++--
 lib/blobchunk.c | 2 +-
 lib/compress.c  | 4 ++--
 lib/gzran.c     | 4 ++--
 lib/inode.c     | 2 +-
 lib/namei.c     | 2 +-
 lib/super.c     | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index 9eebcb8..28f104b 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -694,7 +694,7 @@ static void erofsdump_show_superblock(void)
 	for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
 		if (!feature_lists[i].compat)
 			continue;
-		if (le32_to_cpu(g_sbi.feature_compat) & feature_lists[i].flag) {
+		if (g_sbi.feature_compat & feature_lists[i].flag) {
 			fprintf(stdout, "%s ", feature_lists[i].name);
 			if (feature_lists[i].lkver > minkver)
 				minkver = feature_lists[i].lkver;
@@ -704,7 +704,7 @@ static void erofsdump_show_superblock(void)
 	for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
 		if (feature_lists[i].compat)
 			continue;
-		if (le32_to_cpu(g_sbi.feature_incompat) & feature_lists[i].flag) {
+		if (g_sbi.feature_incompat & feature_lists[i].flag) {
 			fprintf(stdout, "%s ", feature_lists[i].name);
 			if (feature_lists[i].lkver > minkver)
 				minkver = feature_lists[i].lkver;
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index d307a4f..f969cf2 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -245,7 +245,7 @@ int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf,
 		startblk &= addrmask;
 		idx.device_id = cpu_to_le16(chunk->device_id);
 		idx.startblk_lo = cpu_to_le32(startblk);
-		idx.startblk_hi = cpu_to_le32(startblk >> 32);
+		idx.startblk_hi = cpu_to_le16(startblk >> 32);
 		DBG_BUGON(!_48bit && idx.startblk_hi);
 
 		if (unit == EROFS_BLOCK_MAP_ENTRY_SIZE)
diff --git a/lib/compress.c b/lib/compress.c
index 9262afa..9bbb127 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -2153,9 +2153,9 @@ static int z_erofs_build_compr_cfgs(struct erofs_importer *im,
 		} __packed zalg = {
 			.size = cpu_to_le16(sizeof(struct z_erofs_deflate_cfgs)),
 			.z = {
-				.windowbits = cpu_to_le32(ilog2(
+				.windowbits = ilog2(
 					max_dict_size
-						[Z_EROFS_COMPRESSION_DEFLATE])),
+						[Z_EROFS_COMPRESSION_DEFLATE]),
 			}
 		};
 
diff --git a/lib/gzran.c b/lib/gzran.c
index 3973c1f..a75756c 100644
--- a/lib/gzran.c
+++ b/lib/gzran.c
@@ -208,7 +208,7 @@ struct erofs_gzran_iostream {
 	struct erofs_vfile *vin;
 	struct erofs_gzran_cutpoint *cp;
 	u32 entries;
-	u32 span_size;
+	u64 span_size;
 };
 
 static void erofs_gzran_ios_vfclose(struct erofs_vfile *vf)
@@ -346,7 +346,7 @@ struct erofs_vfile *erofs_gzran_zinfo_open(struct erofs_vfile *vin,
 	ios = (struct erofs_gzran_iostream *)vf->payload;
 	h = zinfo_buf;
 	ios->entries = le32_to_cpu(h->have);
-	ios->span_size = le32_to_cpu(h->span_size);
+	ios->span_size = le64_to_cpu(h->span_size);
 
 	v2_size = sizeof(*c) * ios->entries + sizeof(*h);
 	if (!len || v2_size == len) {
diff --git a/lib/inode.c b/lib/inode.c
index 0547b60..a69439c 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -851,7 +851,7 @@ int erofs_iflush(struct erofs_inode *inode)
 
 		u.dic.i_uid = cpu_to_le16((u16)inode->i_uid);
 		u.dic.i_gid = cpu_to_le16((u16)inode->i_gid);
-		u.dic.i_mtime = cpu_to_le64(inode->i_mtime - sbi->epoch);
+		u.dic.i_mtime = cpu_to_le32(inode->i_mtime - sbi->epoch);
 		u.dic.i_u = u1;
 
 		if (nlink_1) {
diff --git a/lib/namei.c b/lib/namei.c
index f19e4b1..9d04693 100644
--- a/lib/namei.c
+++ b/lib/namei.c
@@ -96,7 +96,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 		vi->i_nlink = le32_to_cpu(die->i_nlink);
 
 		vi->i_mtime = le64_to_cpu(die->i_mtime);
-		vi->i_mtime_nsec = le64_to_cpu(die->i_mtime_nsec);
+		vi->i_mtime_nsec = le32_to_cpu(die->i_mtime_nsec);
 		vi->i_size = le64_to_cpu(die->i_size);
 		break;
 	case EROFS_INODE_LAYOUT_COMPACT:
diff --git a/lib/super.c b/lib/super.c
index 25116fe..98e1711 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -222,7 +222,7 @@ int erofs_writesb(struct erofs_sb_info *sbi)
 		.rb.rootnid_2b  = cpu_to_le16(sbi->root_nid),
 		.inos      = cpu_to_le64(sbi->inos),
 		.epoch     = cpu_to_le64(sbi->epoch),
-		.build_time = cpu_to_le64(sbi->build_time),
+		.build_time = cpu_to_le32(sbi->build_time),
 		.fixed_nsec = cpu_to_le32(sbi->fixed_nsec),
 		.meta_blkaddr  = cpu_to_le32(sbi->meta_blkaddr),
 		.xattr_blkaddr = cpu_to_le32(sbi->xattr_blkaddr),

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-28  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27  2:06 [PATCH] erofs-utils: fix incorrect field conversions Yifan Zhao
2026-08-28  8:29 ` [PATCH v2] " Yifan Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.