OSDN Git Service

scsi: target: iscsi: Fix clang -Wformat warnings
authorJustin Stitt <justinstitt@google.com>
Mon, 18 Jul 2022 18:04:21 +0000 (11:04 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 19 Jul 2022 03:04:12 +0000 (23:04 -0400)
commit71b25693b22ebb9391b27f011d3f4bf9762e24f9
treed06a893675c4243c714890faf98cfe0a377ba62f
parentca452621b82916a81ea0f10f9f0158815f3365d0
scsi: target: iscsi: Fix clang -Wformat warnings

When building with Clang we encounter these warnings:
| drivers/target/iscsi/iscsi_target_login.c:719:24: error: format
| specifies type 'unsigned short' but the argument has type 'int'
| [-Werror,-Wformat] " from node: %s\n", atomic_read(&sess->nconn),
-
| drivers/target/iscsi/iscsi_target_login.c:767:12: error: format
| specifies type 'unsigned short' but the argument has type 'int'
| [-Werror,-Wformat] " %s\n", atomic_read(&sess->nconn),
-
| drivers/target/iscsi/iscsi_target.c:4365:12: error: format specifies
| type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
| " %s\n", atomic_read(&sess->nconn)

For all warnings, the format specifier is '%hu' which describes an unsigned
short. The resulting type of atomic_read is an int. The proposed fix is to
listen to Clang and swap the format specifier.

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Link: https://lore.kernel.org/r/20220718180421.49697-1-justinstitt@google.com
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_login.c