From: Nathan Chancellor <nathan@kernel.org> To: jaegeuk@kernel.org, chao@kernel.org Cc: ndesaulniers@google.com, trix@redhat.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, kernel test robot <lkp@intel.com>, Nathan Chancellor <nathan@kernel.org> Subject: [PATCH] f2fs: Fix type of single bit bitfield in f2fs_io_info Date: Wed, 01 Feb 2023 09:40:22 -0700 [thread overview] Message-ID: <20230201-f2fs-fix-single-length-bitfields-v1-1-e386f7916b94@kernel.org> (raw) 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. Fixes: 998863dadd2c ("f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info") Link: https://github.com/ClangBuiltLinux/linux/issues/1796 Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- fs/f2fs/f2fs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 08dc64c5050e..89f6fdfeed19 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -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, -- Nathan Chancellor <nathan@kernel.org>
WARNING: multiple messages have this Message-ID (diff)
From: Nathan Chancellor <nathan@kernel.org> To: jaegeuk@kernel.org, chao@kernel.org Cc: kernel test robot <lkp@intel.com>, trix@redhat.com, llvm@lists.linux.dev, ndesaulniers@google.com, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, linux-f2fs-devel@lists.sourceforge.net Subject: [f2fs-dev] [PATCH] f2fs: Fix type of single bit bitfield in f2fs_io_info Date: Wed, 01 Feb 2023 09:40:22 -0700 [thread overview] Message-ID: <20230201-f2fs-fix-single-length-bitfields-v1-1-e386f7916b94@kernel.org> (raw) 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. Fixes: 998863dadd2c ("f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info") Link: https://github.com/ClangBuiltLinux/linux/issues/1796 Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- fs/f2fs/f2fs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 08dc64c5050e..89f6fdfeed19 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -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, -- Nathan Chancellor <nathan@kernel.org> _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next reply other threads:[~2023-02-01 16:40 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-01 16:40 Nathan Chancellor [this message] 2023-02-01 16:40 ` [f2fs-dev] [PATCH] f2fs: Fix type of single bit bitfield in f2fs_io_info Nathan Chancellor 2023-02-02 6:13 ` Chao Yu 2023-02-02 6:13 ` [f2fs-dev] " Chao Yu 2023-02-02 6:15 ` Nathan Chancellor 2023-02-02 6:15 ` [f2fs-dev] " Nathan Chancellor 2023-02-02 7:11 ` Chao Yu 2023-02-02 7:11 ` [f2fs-dev] " Chao Yu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230201-f2fs-fix-single-length-bitfields-v1-1-e386f7916b94@kernel.org \ --to=nathan@kernel.org \ --cc=chao@kernel.org \ --cc=jaegeuk@kernel.org \ --cc=linux-f2fs-devel@lists.sourceforge.net \ --cc=linux-kernel@vger.kernel.org \ --cc=lkp@intel.com \ --cc=llvm@lists.linux.dev \ --cc=ndesaulniers@google.com \ --cc=patches@lists.linux.dev \ --cc=trix@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.