* [PATCH] staging: replace snprintf with sysfs_emit
@ 2021-11-30 0:07 davidcomponentone
2021-11-30 1:17 ` Joe Perches
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: davidcomponentone @ 2021-11-30 0:07 UTC (permalink / raw)
To: TheSven73
Cc: davidcomponentone, gregkh, linux-staging, linux-kernel,
Yang Guang, Zeal Robot
From: Yang Guang <yang.guang5@zte.com.cn>
coccinelle report:
./drivers/staging/fieldbus/dev_core.c:73:8-16:
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: Yang Guang <yang.guang5@zte.com.cn>
---
drivers/staging/fieldbus/dev_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
index 5aab734606ea..01862fe8e4cc 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
* card_name was provided by child driver, could potentially be long.
* protect against buffer overrun.
*/
- return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
+ return sysfs_emit(buf, "%s\n", fb->card_name);
}
static DEVICE_ATTR_RO(card_name);
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] staging: replace snprintf with sysfs_emit 2021-11-30 0:07 [PATCH] staging: replace snprintf with sysfs_emit davidcomponentone @ 2021-11-30 1:17 ` Joe Perches 2021-11-30 6:42 ` Greg KH 2021-11-30 9:35 ` Dan Carpenter 2 siblings, 0 replies; 4+ messages in thread From: Joe Perches @ 2021-11-30 1:17 UTC (permalink / raw) To: davidcomponentone, TheSven73 Cc: gregkh, linux-staging, linux-kernel, Yang Guang, Zeal Robot On Tue, 2021-11-30 at 08:07 +0800, davidcomponentone@gmail.com wrote: > From: Yang Guang <yang.guang5@zte.com.cn> > > coccinelle report: > ./drivers/staging/fieldbus/dev_core.c:73:8-16: > WARNING: use scnprintf or sprintf > > Use sysfs_emit instead of scnprintf or sprintf makes more sense. Please convert all the show functions and not just 1 of the 6 possible cases. > diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c [] > @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr, > * card_name was provided by child driver, could potentially be long. > * protect against buffer overrun. > */ > - return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name); > + return sysfs_emit(buf, "%s\n", fb->card_name); > } > static DEVICE_ATTR_RO(card_name); > --- drivers/staging/fieldbus/dev_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c index 5aab734606eae..9c85bf87a8d7f 100644 --- a/drivers/staging/fieldbus/dev_core.c +++ b/drivers/staging/fieldbus/dev_core.c @@ -28,7 +28,7 @@ static ssize_t online_show(struct device *dev, struct device_attribute *attr, { struct fieldbus_dev *fb = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", !!fb->online); + return sysfs_emit(buf, "%d\n", !!fb->online); } static DEVICE_ATTR_RO(online); @@ -39,7 +39,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr, if (!fb->enable_get) return -EINVAL; - return sprintf(buf, "%d\n", !!fb->enable_get(fb)); + return sysfs_emit(buf, "%d\n", !!fb->enable_get(fb)); } static ssize_t enabled_store(struct device *dev, struct device_attribute *attr, @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr, * card_name was provided by child driver, could potentially be long. * protect against buffer overrun. */ - return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name); + return sysfs_emit(buf, "%s\n", fb->card_name); } static DEVICE_ATTR_RO(card_name); @@ -79,7 +79,7 @@ static ssize_t read_area_size_show(struct device *dev, { struct fieldbus_dev *fb = dev_get_drvdata(dev); - return sprintf(buf, "%zu\n", fb->read_area_sz); + return sysfs_emit(buf, "%zu\n", fb->read_area_sz); } static DEVICE_ATTR_RO(read_area_size); @@ -88,7 +88,7 @@ static ssize_t write_area_size_show(struct device *dev, { struct fieldbus_dev *fb = dev_get_drvdata(dev); - return sprintf(buf, "%zu\n", fb->write_area_sz); + return sysfs_emit(buf, "%zu\n", fb->write_area_sz); } static DEVICE_ATTR_RO(write_area_size); @@ -116,7 +116,7 @@ static ssize_t fieldbus_type_show(struct device *dev, break; } - return sprintf(buf, "%s\n", t); + return sysfs_emit(buf, "%s\n", t); } static DEVICE_ATTR_RO(fieldbus_type); ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: replace snprintf with sysfs_emit 2021-11-30 0:07 [PATCH] staging: replace snprintf with sysfs_emit davidcomponentone 2021-11-30 1:17 ` Joe Perches @ 2021-11-30 6:42 ` Greg KH 2021-11-30 9:35 ` Dan Carpenter 2 siblings, 0 replies; 4+ messages in thread From: Greg KH @ 2021-11-30 6:42 UTC (permalink / raw) To: davidcomponentone Cc: TheSven73, linux-staging, linux-kernel, Yang Guang, Zeal Robot On Tue, Nov 30, 2021 at 08:07:21AM +0800, davidcomponentone@gmail.com wrote: > From: Yang Guang <yang.guang5@zte.com.cn> > > coccinelle report: > ./drivers/staging/fieldbus/dev_core.c:73:8-16: > WARNING: use scnprintf or sprintf > > Use sysfs_emit instead of scnprintf or sprintf makes more sense. > > Reported-by: Zeal Robot <zealci@zte.com.cn> No, the coccinelle scripts reported this. > Signed-off-by: Yang Guang <yang.guang5@zte.com.cn> None of these email addresses match up with the address you sent this patch from, please fix. thanks, greg k-h ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: replace snprintf with sysfs_emit 2021-11-30 0:07 [PATCH] staging: replace snprintf with sysfs_emit davidcomponentone 2021-11-30 1:17 ` Joe Perches 2021-11-30 6:42 ` Greg KH @ 2021-11-30 9:35 ` Dan Carpenter 2 siblings, 0 replies; 4+ messages in thread From: Dan Carpenter @ 2021-11-30 9:35 UTC (permalink / raw) To: davidcomponentone Cc: TheSven73, gregkh, linux-staging, linux-kernel, Yang Guang, Zeal Robot The Subject needs to have the driver name. Do a `git log --oneline drivers/staging/fieldbus/dev_core.c` to see how the driver authors are naming their patches. [PATCH] staging: fieldbus: replace snprintf with sysfs_emit ^^^^^^^^^ regards, dan carpenter ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-30 9:36 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-11-30 0:07 [PATCH] staging: replace snprintf with sysfs_emit davidcomponentone 2021-11-30 1:17 ` Joe Perches 2021-11-30 6:42 ` Greg KH 2021-11-30 9:35 ` Dan Carpenter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox