Skip to content

Commit

Permalink
scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct …
Browse files Browse the repository at this point in the history
…ibmvfc_host'

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: 5144905 ("scsi: ibmvfc: Use a bitfield for boolean flags")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20231010-ibmvfc-fix-bitfields-type-v1-1-37e95b5a60e5@kernel.org
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Nathan Chancellor authored and Martin K. Petersen committed Oct 13, 2023
1 parent 4df105f commit 78882c7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/scsi/ibmvscsi/ibmvfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 78882c7

Please sign in to comment.