summaryrefslogtreecommitdiff
path: root/drivers/net/phy/sfp.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2017-12-29 12:15:12 +0000
committerDavid S. Miller <davem@davemloft.net>2018-01-02 21:45:32 -0500
commita2f247ef4d25fce3eaf260294bc1e16970c2a2d2 (patch)
treea30b7b392e14346881d970029861af6b36fca00b /drivers/net/phy/sfp.c
parentdc917aec77c0255ba20d582a72a0137f7321f17c (diff)
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: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/sfp.c')
-rw-r--r--drivers/net/phy/sfp.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index ee6b2e041171..6c7d9289078d 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -466,11 +466,6 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
{
/* SFP module inserted - read I2C data */
struct sfp_eeprom_id id;
- char vendor[17];
- char part[17];
- char sn[17];
- char date[9];
- char rev[5];
u8 check;
int err;
@@ -506,19 +501,12 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
sfp->id = id;
- memcpy(vendor, sfp->id.base.vendor_name, 16);
- vendor[16] = '\0';
- memcpy(part, sfp->id.base.vendor_pn, 16);
- part[16] = '\0';
- memcpy(rev, sfp->id.base.vendor_rev, 4);
- rev[4] = '\0';
- 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);
+ dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %.*s\n",
+ (int)sizeof(id.base.vendor_name), id.base.vendor_name,
+ (int)sizeof(id.base.vendor_pn), id.base.vendor_pn,
+ (int)sizeof(id.base.vendor_rev), id.base.vendor_rev,
+ (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn,
+ (int)sizeof(id.ext.datecode), id.ext.datecode);
/* Check whether we support this module */
if (!sfp->type->module_supported(&sfp->id)) {