* [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
@ 2023-10-10 20:32 Nathan Chancellor
2023-10-10 20:50 ` Nick Desaulniers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-10-10 20:32 UTC (permalink / raw)
To: tyreld, martin.petersen
Cc: jejb, ndesaulniers, trix, brking, linux-scsi, linuxppc-dev, llvm,
patches, Nathan Chancellor
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>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
2023-10-10 20:32 [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host' Nathan Chancellor
@ 2023-10-10 20:50 ` Nick Desaulniers
2023-10-13 18:13 ` Martin K. Petersen
2023-10-17 1:11 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2023-10-10 20:50 UTC (permalink / raw)
To: Nathan Chancellor
Cc: tyreld, martin.petersen, jejb, trix, brking, linux-scsi,
linuxppc-dev, llvm, patches
On Tue, Oct 10, 2023 at 1:32 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> 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>
Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> 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>
>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
2023-10-10 20:32 [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host' Nathan Chancellor
2023-10-10 20:50 ` Nick Desaulniers
@ 2023-10-13 18:13 ` Martin K. Petersen
2023-10-17 1:11 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-10-13 18:13 UTC (permalink / raw)
To: Nathan Chancellor
Cc: tyreld, martin.petersen, jejb, ndesaulniers, trix, brking,
linux-scsi, linuxppc-dev, llvm, patches
Nathan,
> 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;
> | ^ ~
>
Applied to 6.7/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
2023-10-10 20:32 [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host' Nathan Chancellor
2023-10-10 20:50 ` Nick Desaulniers
2023-10-13 18:13 ` Martin K. Petersen
@ 2023-10-17 1:11 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-10-17 1:11 UTC (permalink / raw)
To: tyreld, Nathan Chancellor
Cc: Martin K . Petersen, jejb, ndesaulniers, trix, brking, linux-scsi,
linuxppc-dev, llvm, patches
On Tue, 10 Oct 2023 13:32:37 -0700, Nathan Chancellor wrote:
> 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;
> | ^ ~
>
> [...]
Applied to 6.7/scsi-queue, thanks!
[1/1] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host'
https://git.kernel.org/mkp/scsi/c/78882c7657bb
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-17 1:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-10 20:32 [PATCH] scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ibmvfc_host' Nathan Chancellor
2023-10-10 20:50 ` Nick Desaulniers
2023-10-13 18:13 ` Martin K. Petersen
2023-10-17 1:11 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox