staging: fieldbus: Use sysfs_emit for show(device *...) functions
PATCH 1/1 staging: fieldbus: Use sysfs_emit for show(device *...) functions
Convert snprintf calls in device show functions to sysfs_emit for PAGE_SIZE buffer safety.
Warning generated by: scripts/coccinelle/api/device_attr_show.cocci
--- drivers/staging/fieldbus/dev_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fieldbus/dev_core.c +1 -1
@@ -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);
Signature · 1 line
2.25.1
Hi Deepak, thank you for the patch.
There are many other sysfs show functions in this driver that can be converted to use sysfs_emit().
But, the perfect musn't be the enemy of the good:
Quoted 26 lines · Deepak R Varma
Convert snprintf calls in device show functions to
sysfs_emitforPAGE_SIZEbuffer safety.
Warning generated by:scripts/coccinelle/api/device_attr_show.cocciSigned-off-by Deepak R Varma <[email protected]>--- drivers/staging/fieldbus/dev_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/fieldbus/dev_core.c +1
-2@@ -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.25.1
Quoted 4 lines · Sven Van Asbroeck
Hi Deepak, thank you for the patch.
There are many other sysfs show functions in this driver that can be converted to use
sysfs_emit().
Hello Sven & Greg,
Is it okay for me to now change other show functions as suggested for this driver and send another patch?
Just want to confirm since I will be sending the patches from the linux next tree and for the staging driver.
Thank you.
./drv
Quoted 32 lines
But, the perfect musn't be the enemy of the good:
Reviewed-by Sven Van Asbroeck <[email protected]>Quoted 26 lines · Deepak R Varma
Convert snprintf calls in device show functions to
sysfs_emitforPAGE_SIZEbuffer safety.
Warning generated by:scripts/coccinelle/api/device_attr_show.cocciSigned-off-by Deepak R Varma <[email protected]>--- drivers/staging/fieldbus/dev_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/fieldbus/dev_core.c +1
-2@@ -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.25.1