f2fs: Fix type of single bit bitfield in f2fs_io_info
PATCH 1/1 f2fs: Fix type of single bit bitfield in f2fs_io_info
Clang warns:
../fs/f2fs/data.c:995:17: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
fio->submitted = 1;
^ ~
../fs/f2fs/data.c:1011:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
fio->retry = 1;
^ ~ ../fs/f2fs/segment.c:3320:16: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
fio->in_list = 1;
^ ~There is not a bug here because the value of these fields is never explicitly compared against (just whether it is zero or non-zero) but it is easy to silence the warning by using an unsigned type to allow an assignment of 0 or 1 without implicit conversion.
--- fs/f2fs/f2fs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/f2fs/f2fs.h +6 -6
@@ -1213,12 +1213,12 @@ struct f2fs_io_info {int compr_blocks;/* # of compressed block addresses */ int need_lock:8; /* indicate we need to lock cp_rwsem */ int version:8; /* version of the node */ - int submitted:1; /* indicate IO submission */ - int in_list:1; /* indicate fio is in io_list */ - int is_por:1; /* indicate IO is from recovery or not */ - int retry:1; /* need to reallocate block address */ - int encrypted:1; /* indicate file is encrypted */ - int post_read:1; /* require post read */ + unsigned int submitted:1; /* indicate IO submission */ + unsigned int in_list:1; /* indicate fio is in io_list */ + unsigned int is_por:1; /* indicate IO is from recovery or not */ + unsigned int retry:1; /* need to reallocate block address */ + unsigned int encrypted:1; /* indicate file is encrypted */ + unsigned int post_read:1; /* require post read */enum iostat_type io_type;/* io type */ struct writeback_control *io_wbc;/* writeback control */ struct bio **bio;/* bio for ipu */
---
base-commit: de6b3a5e09b29c014bd04044b023896107cfa2ee
change-id: 20230201-f2fs-fix-single-length-bitfields-df8cc78e880a
Best regards,
Signature · 1 line
Nathan Chancellor <[email protected]>
Chao Yu
maintainerQuoted 13 lines · Nathan Chancellor
Clang warns:
../fs/f2fs/data.c:995:17: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->submitted = 1; ^ ~ ../fs/f2fs/data.c:1011:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->retry = 1; ^ ~ ../fs/f2fs/segment.c:3320:16: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->in_list = 1; ^ ~
Quoted 4 lines
There is not a bug here because the value of these fields is never explicitly compared against (just whether it is zero or non-zero) but it is easy to silence the warning by using an unsigned type to allow an assignment of 0 or 1 without implicit conversion.
Nathan, thanks a lot for catching this, do you mind letting I merge this fix into original patch? as the original patch has not been upstreamed yet.
Thanks,
Quoted 14 lines · Chao Yu
Quoted 13 lines · Nathan Chancellor
Clang warns:
../fs/f2fs/data.c:995:17: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->submitted = 1; ^ ~ ../fs/f2fs/data.c:1011:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->retry = 1; ^ ~ ../fs/f2fs/segment.c:3320:16: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->in_list = 1; ^ ~
Quoted 7 lines
Quoted 4 lines
There is not a bug here because the value of these fields is never explicitly compared against (just whether it is zero or non-zero) but it is easy to silence the warning by using an unsigned type to allow an assignment of 0 or 1 without implicit conversion.
Nathan, thanks a lot for catching this, do you mind letting I merge this fix into original patch? as the original patch has not been upstreamed yet.
No worries, do whatever you need to! I just care that the problem gets resolved one way or another :)
Cheers,
Nathan
Chao Yu
maintainerQuoted 20 lines · Nathan Chancellor
Quoted 19 lines · Chao Yu
Quoted 17 lines · Nathan Chancellor
Clang warns:
../fs/f2fs/data.c:995:17: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->submitted = 1; ^ ~ ../fs/f2fs/data.c:1011:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->retry = 1; ^ ~ ../fs/f2fs/segment.c:3320:16: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] fio->in_list = 1; ^ ~There is not a bug here because the value of these fields is never explicitly compared against (just whether it is zero or non-zero) but it is easy to silence the warning by using an unsigned type to allow an assignment of 0 or 1 without implicit conversion.
Quoted 5 lines
Quoted 2 lines
Nathan, thanks a lot for catching this, do you mind letting I merge this fix into original patch? as the original patch has not been upstreamed yet.
No worries, do whatever you need to! I just care that the problem gets resolved one way or another :)
Thank you! Updated a v3 patch. :)
Thanks,
Quoted 3 lines
Cheers,
Nathan