Skip to contentSkip to conversation

scsi: qla2xxx: print port name via %*phC

PATCH Applied Andy Shevchenko 2 participants 2 messages Jan 15, 2015 – Jan 20, 2015

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

PATCH 1/1 scsi: qla2xxx: print port name via %*phC

Instead of pushing each byte via stack let's use custom specifier which allows to print small buffers as a hex string.

---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +1 -3
index 73f9fee..99f43b7 100644
@@ -1570,9 +1570,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
 	 * match the format by tcm_qla2xxx explict ConfigFS NodeACLs.
 	 */
 	memset(&port_name, 0, 36);
-	snprintf(port_name, 36, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
-		fc_wwpn[0], fc_wwpn[1], fc_wwpn[2], fc_wwpn[3], fc_wwpn[4],
-		fc_wwpn[5], fc_wwpn[6], fc_wwpn[7]);
+	snprintf(port_name, sizeof(port_name), "%8phC", fc_wwpn);
 	/*
 	 * Locate our struct se_node_acl either from an explict NodeACL created
 	 * via ConfigFS, or via running in TPG demo mode.
Signature · 1 line
2.1.4
#1 lore raw
Quoted 13 lines · Andy Shevchenko

Instead of pushing each byte via stack let's use custom specifier which allows to print small buffers as a hex string.

---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +0 -0
index 73f9fee..99f43b7 100644

drivers/scsi/qla2xxx/tcm_qla2xxx.c static int tcm_qla2xxx_check_initiator_node_acl( · line 1576

Quoted 10 lines
drivers/scsi/qla2xxx/tcm_qla2xxx.c +1 -3
@@ -1570,9 +1570,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
 	 * match the format by tcm_qla2xxx explict ConfigFS NodeACLs.
 	 */
 	memset(&port_name, 0, 36);
-	snprintf(port_name, 36, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
-		fc_wwpn[0], fc_wwpn[1], fc_wwpn[2], fc_wwpn[3], fc_wwpn[4],
-		fc_wwpn[5], fc_wwpn[6], fc_wwpn[7]);
+	snprintf(port_name, sizeof(port_name), "%8phC", fc_wwpn);
 	/*
 	 * Locate our struct se_node_acl either from an explict NodeACL created
 	 * via ConfigFS, or via running in TPG demo mode.

Picking this one up, since it's specific to tcm_qla2xxx code.

Applied to target-pending/for-next.

Thanks Andy!

--nab