lkml.org 
[lkml]   [2021]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] fsi: master: replace snprintf in show functions with sysfs_emit
From
Date
On Fri, 2021-10-22 at 02:50 +0000, cgel.zte@gmail.com wrote:
> From: Ye Guojin <ye.guojin@zte.com.cn>
>
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING use scnprintf or sprintf
[]
> diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
[]
> @@ -1083,8 +1083,7 @@ static ssize_t external_mode_show(struct device *dev,
> {
> struct fsi_master_acf *master = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> - master->external_mode ? 1 : 0);
> + return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);

external_mode is already bool so this ?: isn't necessary.

> diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
[]
> @@ -718,8 +718,7 @@ static ssize_t external_mode_show(struct device *dev,
> {
> struct fsi_master_gpio *master = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> - master->external_mode ? 1 : 0);
> + return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);

here too

\
 
 \ /
  Last update: 2021-10-22 06:50    [W:0.044 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site