net: can: replace snprintf in show functions with sysfs_emit
PATCH 1/1 net: can: replace snprintf in show functions with sysfs_emit
show() must not use snprintf() when formatting the value to be returned to user space.
Fix the following coccicheck warning:drivers/net/can/at91_can.c:1185: WARNING: use scnprintf or sprintf. drivers/net/can/janz-ican3.c:1834: WARNING: use scnprintf or sprintf.
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- drivers/net/can/at91_can.c | 4 ++-- drivers/net/can/janz-ican3.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/at91_can.c +2 -2
@@ -1182,9 +1182,9 @@ static ssize_t at91_sysfs_show_mb0_id(struct device *dev,struct at91_priv *priv =netdev_priv (to_net_dev (dev));if (priv->mb0_id &CAN_EFF_FLAG ) -return snprintf (buf,PAGE_SIZE ,"0x%08x\n" , priv->mb0_id); +return sysfs_emit (buf,"0x%08x\n" , priv->mb0_id);else -return snprintf (buf,PAGE_SIZE ,"0x%03x\n" , priv->mb0_id); +return sysfs_emit (buf,"0x%03x\n" , priv->mb0_id); } static ssize_t at91_sysfs_set_mb0_id(struct device *dev,
drivers/net/can/janz-ican3.c +1 -1
@@ -1831,7 +1831,7 @@ static ssize_t ican3_sysfs_show_term(struct device *dev,return -ETIMEDOUT ; } -return snprintf (buf,PAGE_SIZE ,"%u\n" , mod->termination_enabled); +return sysfs_emit (buf,"%u\n" , mod->termination_enabled); } static ssize_t ican3_sysfs_set_term(struct device *dev,
Signature · 1 line
2.7.4
Marc Kleine-Budde
maintainerQuoted 10 lines · Qing Wang
show()must not usesnprintf()when formatting the value to be returned to user space.Fix the following coccicheck warning:
drivers/net/can/at91_can.c:1185: WARNING: use scnprintf or sprintf.drivers/net/can/janz-ican3.c:1834: WARNING: use scnprintf or sprintf.Use
sysfs_emitinstead of scnprintf or sprintf makes more sense.Signed-off-by Qing Wang <[email protected]>
Added to linux-can-next/testing.
Thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |