diff mbox series

[v2,2/2] scsi: qedi: Fix SYSFS_FLAG_FW_SEL_BOOT formatting

Message ID 20211126201708.27140-3-f.fainelli@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series scsi: qedi: Couple of warning fixes | expand

Commit Message

Florian Fainelli Nov. 26, 2021, 8:17 p.m. UTC
The format used for formatting SYSFS_FLAG_FW_SEL_BOOT creates the
following warning:

drivers/scsi/qedi/qedi_main.c:2259:35: warning: format specifies type
'char' but the argument has type 'int' [-Wformat]
                   rc = snprintf(buf, 3, "%hhd\n",
SYSFS_FLAG_FW_SEL_BOOT);

Fix this to cast the constant as an u8 since the intention is to print
it via sysfs as a byte.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/scsi/qedi/qedi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Manish Rangankar Nov. 29, 2021, 7:29 a.m. UTC | #1
> -----Original Message-----
> From: Florian Fainelli <f.fainelli@gmail.com>
> Sent: Saturday, November 27, 2021 1:47 AM
> To: linux-kernel@vger.kernel.org
> Cc: Florian Fainelli <f.fainelli@gmail.com>; kernel test robot <lkp@intel.com>;
> Nilesh Javali <njavali@marvell.com>; Manish Rangankar
> <mrangankar@marvell.com>; GR-QLogic-Storage-Upstream <GR-QLogic-
> Storage-Upstream@marvell.com>; James E.J. Bottomley <jejb@linux.ibm.com>;
> Martin K. Petersen <martin.petersen@oracle.com>; open list:QLOGIC QL41xxx
> ISCSI DRIVER <linux-scsi@vger.kernel.org>
> Subject: [EXT] [PATCH v2 2/2] scsi: qedi: Fix SYSFS_FLAG_FW_SEL_BOOT
> formatting
> 
> External Email
> 
> ----------------------------------------------------------------------
> The format used for formatting SYSFS_FLAG_FW_SEL_BOOT creates the
> following warning:
> 
> drivers/scsi/qedi/qedi_main.c:2259:35: warning: format specifies type 'char' but
> the argument has type 'int' [-Wformat]
>                    rc = snprintf(buf, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT);
> 
> Fix this to cast the constant as an u8 since the intention is to print it via sysfs as a
> byte.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/scsi/qedi/qedi.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index
> ce199a7a16b8..421b3a69fd37 100644
> --- a/drivers/scsi/qedi/qedi.h
> +++ b/drivers/scsi/qedi/qedi.h
> @@ -358,7 +358,7 @@ struct qedi_ctx {
>  	bool use_fast_sge;
> 
>  	atomic_t num_offloads;
> -#define SYSFS_FLAG_FW_SEL_BOOT 2
> +#define SYSFS_FLAG_FW_SEL_BOOT (u8)2
>  #define IPV6_LEN	41
>  #define IPV4_LEN	17
>  	struct iscsi_boot_kset *boot_kset;
> --
> 2.25.1

Acked-by: Manish Rangankar <mrangankar@marvell.com>
Martin K. Petersen Nov. 30, 2021, 3:59 a.m. UTC | #2
Florian,

> The format used for formatting SYSFS_FLAG_FW_SEL_BOOT creates the
> following warning:
>
> drivers/scsi/qedi/qedi_main.c:2259:35: warning: format specifies type
> 'char' but the argument has type 'int' [-Wformat]
>                    rc = snprintf(buf, 3, "%hhd\n",
> SYSFS_FLAG_FW_SEL_BOOT);
>
> Fix this to cast the constant as an u8 since the intention is to print
> it via sysfs as a byte.

The other occurrences of SYSFS_FLAG_FW_SEL_BOOT use "%d". Since %hh is
deprecated I suggest you just fix the snprintf().
Florian Fainelli Nov. 30, 2021, 4:09 a.m. UTC | #3
On 11/29/2021 7:59 PM, Martin K. Petersen wrote:
> 
> Florian,
> 
>> The format used for formatting SYSFS_FLAG_FW_SEL_BOOT creates the
>> following warning:
>>
>> drivers/scsi/qedi/qedi_main.c:2259:35: warning: format specifies type
>> 'char' but the argument has type 'int' [-Wformat]
>>                     rc = snprintf(buf, 3, "%hhd\n",
>> SYSFS_FLAG_FW_SEL_BOOT);
>>
>> Fix this to cast the constant as an u8 since the intention is to print
>> it via sysfs as a byte.
> 
> The other occurrences of SYSFS_FLAG_FW_SEL_BOOT use "%d". Since %hh is
> deprecated I suggest you just fix the snprintf().

That was what v1 did here:

https://lkml.org/lkml/2021/11/26/9

however Manish seemed to want that flag to be printed as a byte I am 
fine either way.
Martin K. Petersen Nov. 30, 2021, 4:25 a.m. UTC | #4
Florian,

>> The other occurrences of SYSFS_FLAG_FW_SEL_BOOT use "%d". Since %hh
>> is deprecated I suggest you just fix the snprintf().
>
> That was what v1 did here:
>
> https://lkml.org/lkml/2021/11/26/9
>
> however Manish seemed to want that flag to be printed as a byte I am
> fine either way.

Not sure I understand the concern since this is a constant which will
always be "2".

But if you must cast, do it in snprintf() and not in the macro
definition. checkpatch also complains about the cast.

I would prefer for all instances of this to be consistent, though. So
whatever you do, please also fix qla4xxx.
diff mbox series

Patch

diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index ce199a7a16b8..421b3a69fd37 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -358,7 +358,7 @@  struct qedi_ctx {
 	bool use_fast_sge;
 
 	atomic_t num_offloads;
-#define SYSFS_FLAG_FW_SEL_BOOT 2
+#define SYSFS_FLAG_FW_SEL_BOOT (u8)2
 #define IPV6_LEN	41
 #define IPV4_LEN	17
 	struct iscsi_boot_kset *boot_kset;