lkml.org 
[lkml]   [2022]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] staging: fieldbus: convert snprintf to scnprintf
It is recommended to use scnprintf instead of snprintf to accurately
return the size of the encoded data. Following article [1] has details
on the reason for this kernel level migration. This issue was identified
using coccicheck.

[1] https://lwn.net/Articles/69419/

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
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..d51f2b02d5e6 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 scnprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
}
static DEVICE_ATTR_RO(card_name);

--
2.34.1


\
 
 \ /
  Last update: 2022-11-02 19:26    [W:0.031 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site