erofs-utils: fix incorrect field conversions
PATCH 1/1 erofs-utils: fix incorrect field conversions
Assisted-by Codex:gpt-5.6-sol
Signed-off-by Yifan Zhao <[email protected]>
--- 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(-)
dump/main.c +2 -2
@@ -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;
lib/compress.c +2 -2
@@ -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 ]), } };
lib/gzran.c +2 -2
@@ -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) {
lib/inode.c +1 -1
@@ -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) {
lib/namei.c +1 -1
@@ -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 :
lib/super.c +1 -1
@@ -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),
Signature · 1 line
2.55.0
PATCH v2 1/1 erofs-utils: fix incorrect field conversions
Assisted-by Codex:gpt-5.6-sol
Signed-off-by Yifan Zhao <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
---
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(-)
dump/main.c +2 -2
@@ -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;
lib/blobchunk.c +1 -1
@@ -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 )
lib/compress.c +2 -2
@@ -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 ]), } };
lib/gzran.c +2 -2
@@ -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) {
lib/inode.c +1 -1
@@ -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) {
lib/namei.c +1 -1
@@ -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 :
lib/super.c +1 -1
@@ -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),
Signature · 1 line
2.55.0