]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
can: at91/janz-ican3: replace snprintf() in show functions with sysfs_emit()
authorQing Wang <wangqing@vivo.com>
Fri, 15 Oct 2021 06:50:24 +0000 (23:50 -0700)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Sun, 24 Oct 2021 14:25:42 +0000 (16:25 +0200)
The sysfs show() functions 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.

Link: https://lore.kernel.org/all/1634280624-4816-1-git-send-email-wangqing@vivo.com
Signed-off-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/at91_can.c
drivers/net/can/janz-ican3.c

index b06af90a996408118e660e7c9e391f191dfb582c..3aea32c9b108f9baf6bb98d2a0ee854347b403d2 100644 (file)
@@ -1170,9 +1170,9 @@ static ssize_t mb0_id_show(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 mb0_id_store(struct device *dev,
index c68ad56628bd444a193de02e74a100d057dc77cf..32006dbf5abd5688c257e101b6b04f534751a9ab 100644 (file)
@@ -1831,7 +1831,7 @@ static ssize_t termination_show(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 termination_store(struct device *dev,