Commit a2f247ef authored by Russell King's avatar Russell King Committed by David S. Miller

sfp: use precision to print non-null terminated strings

Rather than memcpy()'ing the strings and null terminate them, printf
allows non-NULL terminated strings provided the precision is not more
than the size of the buffer.  Use this form to print the basic module
information rather than copying and terminating the strings.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dc917aec
...@@ -466,11 +466,6 @@ static int sfp_sm_mod_probe(struct sfp *sfp) ...@@ -466,11 +466,6 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
{ {
/* SFP module inserted - read I2C data */ /* SFP module inserted - read I2C data */
struct sfp_eeprom_id id; struct sfp_eeprom_id id;
char vendor[17];
char part[17];
char sn[17];
char date[9];
char rev[5];
u8 check; u8 check;
int err; int err;
...@@ -506,19 +501,12 @@ static int sfp_sm_mod_probe(struct sfp *sfp) ...@@ -506,19 +501,12 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
sfp->id = id; sfp->id = id;
memcpy(vendor, sfp->id.base.vendor_name, 16); dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %.*s\n",
vendor[16] = '\0'; (int)sizeof(id.base.vendor_name), id.base.vendor_name,
memcpy(part, sfp->id.base.vendor_pn, 16); (int)sizeof(id.base.vendor_pn), id.base.vendor_pn,
part[16] = '\0'; (int)sizeof(id.base.vendor_rev), id.base.vendor_rev,
memcpy(rev, sfp->id.base.vendor_rev, 4); (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn,
rev[4] = '\0'; (int)sizeof(id.ext.datecode), id.ext.datecode);
memcpy(sn, sfp->id.ext.vendor_sn, 16);
sn[16] = '\0';
memcpy(date, sfp->id.ext.datecode, 8);
date[8] = '\0';
dev_info(sfp->dev, "module %s %s rev %s sn %s dc %s\n",
vendor, part, rev, sn, date);
/* Check whether we support this module */ /* Check whether we support this module */
if (!sfp->type->module_supported(&sfp->id)) { if (!sfp->type->module_supported(&sfp->id)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment