Skip to contentSkip to conversation

iscsi: iscsi_target: fix clang -Wformat warning

PATCH In review Justin Stitt 2 participants 2 messages Jul 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iscsi: iscsi_target: fix clang -Wformat warning

When building with Clang we encounter this warning:

| 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)

The format specifier used is %hu which describes an unsigned short. However, atomic_read returns an int which means the format specifier should be %d.

---
 drivers/target/iscsi/iscsi_target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +1 -1
index e368f038ff5c..bfb717065344 100644
@@ -4361,7 +4361,7 @@ int iscsit_close_connection(
 
 	spin_lock_bh(&sess->conn_lock);
 	atomic_dec(&sess->nconn);
-	pr_debug("Decremented iSCSI connection count to %hu from node:"
+	pr_debug("Decremented iSCSI connection count to %d from node:"
 		" %s\n", atomic_read(&sess->nconn),
 		sess->sess_ops->InitiatorName);
 	/*
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
#1 lore raw
Quoted 9 lines · Justin Stitt

When building with Clang we encounter this warning:

| 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)

The format specifier used is %hu which describes an unsigned short. However, atomic_read returns an int which means the format specifier should be %d.

Thanks for the patches!

Please fold this into:
https://lore.kernel.org/llvm/[email protected]/
and send a v2 of that.

Quoted 23 lines
---
 drivers/target/iscsi/iscsi_target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +1 -2
index e368f038ff5c..bfb717065344 100644
@@ -4361,7 +4361,7 @@ int iscsit_close_connection(
 
        spin_lock_bh(&sess->conn_lock);
        atomic_dec(&sess->nconn);
-       pr_debug("Decremented iSCSI connection count to %hu from node:"
+       pr_debug("Decremented iSCSI connection count to %d from node:"
                " %s\n", atomic_read(&sess->nconn),
                sess->sess_ops->InitiatorName);
        /*
--

2.37.0.rc0.161.g10f37bed90-goog

Signature · 2 lines
Thanks,
~Nick Desaulniers