From: Nathan Chancellor <nathan@kernel.org>
To: tyreld@linux.ibm.com, martin.petersen@oracle.com
Cc: jejb@linux.ibm.com, ndesaulniers@google.com, trix@redhat.com,
brking@linux.vnet.ibm.com, linux-scsi@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, llvm@lists.linux.dev,
patches@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
Date: Tue, 10 Oct 2023 13:32:37 -0700 [thread overview]
Message-ID: <20231010-ibmvfc-fix-bitfields-type-v1-1-37e95b5a60e5@kernel.org> (raw)
Clang warns (or errors with CONFIG_WERROR=y) several times along the
lines of:
drivers/scsi/ibmvscsi/ibmvfc.c:650:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
650 | vhost->reinit = 1;
| ^ ~
A single-bit signed integer bitfield only has possible values of -1 and
0, not 0 and 1 like an unsigned one would. No context appears to check
the actual value of these bitfields, just whether or not it is zero.
However, it is easy enough to change the type of the fields to 'unsigned
int', which keeps the same size in memory and resolves the warning.
Fixes: 5144905884e2 ("scsi: ibmvfc: Use a bitfield for boolean flags")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/scsi/ibmvscsi/ibmvfc.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
index 331ecf8254be..745ad5ac7251 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.h
+++ b/drivers/scsi/ibmvscsi/ibmvfc.h
@@ -892,15 +892,15 @@ struct ibmvfc_host {
int init_retries;
int discovery_threads;
int abort_threads;
- int client_migrated:1;
- int reinit:1;
- int delay_init:1;
- int logged_in:1;
- int mq_enabled:1;
- int using_channels:1;
- int do_enquiry:1;
- int aborting_passthru:1;
- int scan_complete:1;
+ unsigned int client_migrated:1;
+ unsigned int reinit:1;
+ unsigned int delay_init:1;
+ unsigned int logged_in:1;
+ unsigned int mq_enabled:1;
+ unsigned int using_channels:1;
+ unsigned int do_enquiry:1;
+ unsigned int aborting_passthru:1;
+ unsigned int scan_complete:1;
int scan_timeout;
int events_to_log;
#define IBMVFC_AE_LINKUP 0x0001
---
base-commit: b6f2e063017b92491976a40c32a0e4b3c13e7d2f
change-id: 20231010-ibmvfc-fix-bitfields-type-971a07c64ec6
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
next reply other threads:[~2023-10-10 20:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 20:32 Nathan Chancellor [this message]
2023-10-10 20:50 ` [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host' Nick Desaulniers
2023-10-13 18:13 ` Martin K. Petersen
2023-10-17 1:11 ` Martin K. Petersen
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=20231010-ibmvfc-fix-bitfields-type-v1-1-37e95b5a60e5@kernel.org \
--to=nathan@kernel.org \
--cc=brking@linux.vnet.ibm.com \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=llvm@lists.linux.dev \
--cc=martin.petersen@oracle.com \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=trix@redhat.com \
--cc=tyreld@linux.ibm.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox