sparc: vio: use sysfs_emit in sysfs show functions
PATCH RESEND 1/1 sparc: vio: use sysfs_emit in sysfs show functions
Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() is preferred to format sysfs output as it provides better bounds checking.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/sparc/kernel/vio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/sparc/kernel/vio.c +5 -4
@@ -13,6 +13,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/sysfs.h> #include <linux/irq.h> #include <linux/export.h> #include <linux/init.h>
@@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,else if (!strcmp (vdev->type,"vdc-port" )) str ="vdisk" ; -return sprintf (buf,"%s\n" , str); +return sysfs_emit (buf,"%s\n" , str); }static DEVICE_ATTR_RO (devspec);
@@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct vio_dev *vdev = to_vio_dev(dev); -return sprintf (buf,"%s\n" , vdev->type); +return sysfs_emit (buf,"%s\n" , vdev->type); }static DEVICE_ATTR_RO (type);
@@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, {const struct vio_dev *vdev =to_vio_dev (dev); -return sprintf (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); +return sysfs_emit (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); }static DEVICE_ATTR_RO (modalias);
@@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr, vdev =to_vio_dev (dev); dp = vdev->dp; -return scnprintf (buf,PAGE_SIZE ,"%pOF\n" , dp); +return sysfs_emit (buf,"%pOF\n" , dp); } static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
Gentle ping?
Quoted 57 lines · Thorsten Blum
Replace
sprintf()andscnprintf()withsysfs_emit()in sysfs show functions.sysfs_emit()is preferred to format sysfs output as it provides better bounds checking.Signed-off-by Thorsten Blum <[email protected]>--- arch/sparc/kernel/vio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)arch/sparc/kernel/vio.c +5
-4@@ -13,6 +13,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/sysfs.h> #include <linux/irq.h> #include <linux/export.h> #include <linux/init.h> @@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,else if (!strcmp (vdev->type,"vdc-port" )) str ="vdisk" ; -return sprintf (buf,"%s\n" , str); +return sysfs_emit (buf,"%s\n" , str); }static DEVICE_ATTR_RO (devspec);@@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct vio_dev *vdev = to_vio_dev(dev); -return sprintf (buf,"%s\n" , vdev->type); +return sysfs_emit (buf,"%s\n" , vdev->type); }static DEVICE_ATTR_RO (type);@@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, {const struct vio_dev *vdev =to_vio_dev (dev); -return sprintf (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); +return sysfs_emit (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); }static DEVICE_ATTR_RO (modalias);@@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr, vdev =to_vio_dev (dev); dp = vdev->dp; -return scnprintf (buf,PAGE_SIZE ,"%pOF\n" , dp); +return sysfs_emit (buf,"%pOF\n" , dp); } static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
Quoted 49 lines · Thorsten Blum
Replace
sprintf()andscnprintf()withsysfs_emit()in sysfs show functions.sysfs_emit()is preferred to format sysfs output as it provides better bounds checking.Signed-off-by Thorsten Blum <[email protected]>--- arch/sparc/kernel/vio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)arch/sparc/kernel/vio.c +4
-3@@ -13,6 +13,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/sysfs.h> #include <linux/irq.h> #include <linux/export.h> #include <linux/init.h> @@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,else if (!strcmp (vdev->type,"vdc-port" )) str ="vdisk" ; -return sprintf (buf,"%s\n" , str); +return sysfs_emit (buf,"%s\n" , str); }static DEVICE_ATTR_RO (devspec);@@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct vio_dev *vdev = to_vio_dev(dev); -return sprintf (buf,"%s\n" , vdev->type); +return sysfs_emit (buf,"%s\n" , vdev->type); }static DEVICE_ATTR_RO (type);@@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, {const struct vio_dev *vdev =to_vio_dev (dev); -return sprintf (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); +return sysfs_emit (buf,"vio:T%sS%s\n" , vdev->type, vdev->compat); }static DEVICE_ATTR_RO (modalias);
arch/sparc/kernel/vio.c show_pciobppath_attr(struct device *dev, struct device_attribute *attr, · line 199
Quoted 8 lines
arch/sparc/kernel/vio.c +1
-1@@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr, vdev =to_vio_dev (dev); dp = vdev->dp; -return scnprintf (buf,PAGE_SIZE ,"%pOF\n" , dp); +return sysfs_emit (buf,"%pOF\n" , dp); } static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
Reviewed-by Andreas Larsson <[email protected]>
Tested-by Andreas Larsson <[email protected]>
Picking this up to my for-next.
Thanks,
Andreas