* [PATCH] fsi: master: replace snprintf in show functions with sysfs_emit
@ 2021-10-22 2:50 cgel.zte
2021-10-22 4:49 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-10-22 2:50 UTC (permalink / raw)
To: jk
Cc: joel, alistair, eajames, linux-fsi, linux-kernel, Ye Guojin, Zeal Robot
From: Ye Guojin <ye.guojin@zte.com.cn>
coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
---
drivers/fsi/fsi-master-ast-cf.c | 3 +--
drivers/fsi/fsi-master-gpio.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
index 24292acdbaf8..1725785128f9 100644
--- 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);
}
static ssize_t external_mode_store(struct device *dev,
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 7d5f29b4b595..865acb37e0ee 100644
--- 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);
}
static ssize_t external_mode_store(struct device *dev,
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fsi: master: replace snprintf in show functions with sysfs_emit
2021-10-22 2:50 [PATCH] fsi: master: replace snprintf in show functions with sysfs_emit cgel.zte
@ 2021-10-22 4:49 ` Joe Perches
2021-10-22 9:02 ` [PATCH v2] " cgel.zte
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2021-10-22 4:49 UTC (permalink / raw)
To: cgel.zte, jk
Cc: joel, alistair, eajames, linux-fsi, linux-kernel, Ye Guojin, Zeal Robot
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] fsi: master: replace snprintf in show functions with sysfs_emit
2021-10-22 4:49 ` Joe Perches
@ 2021-10-22 9:02 ` cgel.zte
0 siblings, 0 replies; 3+ messages in thread
From: cgel.zte @ 2021-10-22 9:02 UTC (permalink / raw)
To: joe
Cc: alistair, cgel.zte, eajames, jk, joel, linux-fsi, linux-kernel,
ye.guojin, zealci
From: Ye Guojin <ye.guojin@zte.com.cn>
coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
---
Changes since v1:
- remove unnecessary ?: since external_mode is already bool.
drivers/fsi/fsi-master-ast-cf.c | 3 +--
drivers/fsi/fsi-master-gpio.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
index 24292acdbaf8..7f3303854e23 100644
--- 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);
}
static ssize_t external_mode_store(struct device *dev,
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 7d5f29b4b595..b8538a851675 100644
--- 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);
}
static ssize_t external_mode_store(struct device *dev,
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-22 9:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 2:50 [PATCH] fsi: master: replace snprintf in show functions with sysfs_emit cgel.zte
2021-10-22 4:49 ` Joe Perches
2021-10-22 9:02 ` [PATCH v2] " cgel.zte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®