[PATCH 3/5] scsi: hpsa: Use vsprintf %phNX extension
From: Joe Perches
Date: Thu Aug 26 2021 - 14:43:20 EST
Reduce object size by using the %phNX extension to format a sysfs output
buffer with identical output.
compiled x86-64 defconfig w/ hpsa and gcc 10.3.0
$ size drivers/scsi/hpsa.o*
text data bss dec hex filename
84041 2181 20 86242 150e2 drivers/scsi/hpsa.o.new
84226 2181 20 86427 1519b drivers/scsi/hpsa.o.old
Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
drivers/scsi/hpsa.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3faa87fa296a2..c56871e8ce1b7 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -743,13 +743,7 @@ static ssize_t unique_id_show(struct device *dev,
}
memcpy(sn, hdev->device_id, sizeof(sn));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 16 * 2 + 2,
- "%02X%02X%02X%02X%02X%02X%02X%02X"
- "%02X%02X%02X%02X%02X%02X%02X%02X\n",
- sn[0], sn[1], sn[2], sn[3],
- sn[4], sn[5], sn[6], sn[7],
- sn[8], sn[9], sn[10], sn[11],
- sn[12], sn[13], sn[14], sn[15]);
+ return snprintf(buf, 16 * 2 + 2, "%16phNX\n", sn);
}
static ssize_t sas_address_show(struct device *dev,
--
2.30.0