iscsi-target: use '%*ph' specifier to dump hex buffer
Subsystems (2)
PATCH 1/1 iscsi-target: use '%*ph' specifier to dump hex buffer
Instead of pushing each byte via stack the %*ph specifier allows to supply just a pointer and length of the buffer. The patch converts code to use the specifier.
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/target/iscsi/iscsi_target_configfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/target/iscsi/iscsi_target_configfs.c +4 -9
@@ -674,12 +674,9 @@ static ssize_t lio_target_nacl_show_info( rb +=sprintf (page+rb,"InitiatorAlias: %s\n" , sess->sess_ops->InitiatorAlias); - rb +=sprintf (page+rb,"LIO Session ID: %u " -"ISID: 0x%02x %02x %02x %02x %02x %02x " -"TSIH: %hu " , sess->sid, - sess->isid[0 ], sess->isid[1 ], sess->isid[2 ], - sess->isid[3 ], sess->isid[4 ], sess->isid[5 ], - sess->tsih); + rb +=sprintf (page+rb, +"LIO Session ID: %u ISID: 0x%6ph TSIH: %hu " , + sess->sid, sess->isid, sess->tsih); rb +=sprintf (page+rb,"SessionType: %s\n" , (sess->sess_ops->SessionType) ?"Discovery" :"Normal" );
@@ -1758,9 +1755,7 @@ static u32 lio_sess_get_initiator_sid(/* * iSCSI Initiator Session Identifier from RFC-3720. */ -return snprintf (buf, size,"%02x%02x%02x%02x%02x%02x" , - sess->isid[0 ], sess->isid[1 ], sess->isid[2 ], - sess->isid[3 ], sess->isid[4 ], sess->isid[5 ]); +return snprintf (buf, size,"%6phN" , sess->isid); }static int lio_queue_data_in (struct se_cmd *se_cmd)
Signature · 1 line
2.1.4
Nicholas A. Bellinger
AppliedQuoted 30 lines · Andy Shevchenko
Instead of pushing each byte via stack the %*ph specifier allows to supply just a pointer and length of the buffer. The patch converts code to use the specifier.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/target/iscsi/iscsi_target_configfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/target/iscsi/iscsi_target_configfs.c +3
-6@@ -674,12 +674,9 @@ static ssize_t lio_target_nacl_show_info( rb +=sprintf (page+rb,"InitiatorAlias: %s\n" , sess->sess_ops->InitiatorAlias); - rb +=sprintf (page+rb,"LIO Session ID: %u " -"ISID: 0x%02x %02x %02x %02x %02x %02x " -"TSIH: %hu " , sess->sid, - sess->isid[0 ], sess->isid[1 ], sess->isid[2 ], - sess->isid[3 ], sess->isid[4 ], sess->isid[5 ], - sess->tsih); + rb +=sprintf (page+rb, +"LIO Session ID: %u ISID: 0x%6ph TSIH: %hu " , + sess->sid, sess->isid, sess->tsih); rb +=sprintf (page+rb,"SessionType: %s\n" , (sess->sess_ops->SessionType) ?"Discovery" :"Normal" );
drivers/target/iscsi/iscsi_target_configfs.c static u32 lio_sess_get_initiator_sid( · line 1761
Quoted 10 lines
drivers/target/iscsi/iscsi_target_configfs.c +1
-3@@ -1758,9 +1755,7 @@ static u32 lio_sess_get_initiator_sid(/* * iSCSI Initiator Session Identifier from RFC-3720. */ -return snprintf (buf, size,"%02x%02x%02x%02x%02x%02x" , - sess->isid[0 ], sess->isid[1 ], sess->isid[2 ], - sess->isid[3 ], sess->isid[4 ], sess->isid[5 ]); +return snprintf (buf, size,"%6phN" , sess->isid); }static int lio_queue_data_in (struct se_cmd *se_cmd)
Applied to target-pending/for-next.
Thanks Andy!
--nab