uacce: use sysfs_emit instead of sprintf
Subsystems (2)
PATCH v3 1/1 uacce: use sysfs_emit instead of sprintf
Use the sysfs_emit to replace sprintf. sprintf may cause output defect in sysfs content, it is better to use new added sysfs_emit function which knows the size of the temporary buffer.
---
changes v1->v2:
modfiy the comments.
changes v2->v3:
modify the "changes" lines.
drivers/misc/uacce/uacce.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/misc/uacce/uacce.c +6 -6
@@ -289,7 +289,7 @@ static ssize_t api_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->api_ver); +return sysfs_emit (buf,"%s\n" , uacce->api_ver); } static ssize_t flags_show(struct device *dev,
@@ -297,7 +297,7 @@ static ssize_t flags_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%u\n" , uacce->flags); +return sysfs_emit (buf,"%u\n" , uacce->flags); } static ssize_t available_instances_show(struct device *dev,
@@ -309,7 +309,7 @@ static ssize_t available_instances_show(struct device *dev,if (!uacce->ops->get_available_instances)return -ENODEV ; -return sprintf (buf,"%d\n" , +return sysfs_emit (buf,"%d\n" , uacce->ops->get_available_instances (uacce)); }
@@ -318,7 +318,7 @@ static ssize_t algorithms_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->algs); +return sysfs_emit (buf,"%s\n" , uacce->algs); } static ssize_t region_mmio_size_show(struct device *dev,
@@ -326,7 +326,7 @@ static ssize_t region_mmio_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_MMIO ] <<PAGE_SHIFT ); }
@@ -335,7 +335,7 @@ static ssize_t region_dus_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_DUS ] <<PAGE_SHIFT ); }
Signature · 1 line
2.33.0
Quoted 66 lines · Kai Ye
Use the
sysfs_emitto replace sprintf. sprintf may cause output defect in sysfs content, it is better to use new addedsysfs_emitfunction which knows the size of the temporary buffer.Signed-off-by Kai Ye <[email protected]>---
changesv1->v2:
modfiy the comments.
changesv2->v3:
modify the "changes" lines.drivers/misc/uacce/uacce.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/misc/uacce/uacce.c +5
-5@@ -289,7 +289,7 @@ static ssize_t api_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->api_ver); +return sysfs_emit (buf,"%s\n" , uacce->api_ver); } static ssize_t flags_show(struct device *dev,@@ -297,7 +297,7 @@ static ssize_t flags_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%u\n" , uacce->flags); +return sysfs_emit (buf,"%u\n" , uacce->flags); } static ssize_t available_instances_show(struct device *dev,@@ -309,7 +309,7 @@ static ssize_t available_instances_show(struct device *dev,if (!uacce->ops->get_available_instances)return -ENODEV ; -return sprintf (buf,"%d\n" , +return sysfs_emit (buf,"%d\n" , uacce->ops->get_available_instances (uacce)); }@@ -318,7 +318,7 @@ static ssize_t algorithms_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->algs); +return sysfs_emit (buf,"%s\n" , uacce->algs); } static ssize_t region_mmio_size_show(struct device *dev,@@ -326,7 +326,7 @@ static ssize_t region_mmio_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_MMIO ] <<PAGE_SHIFT ); }
drivers/misc/uacce/uacce.c static ssize_t region_dus_size_show(struct device *dev, · line 341
Quoted 8 lines
drivers/misc/uacce/uacce.c +1
-1@@ -335,7 +335,7 @@ static ssize_t region_dus_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_DUS ] <<PAGE_SHIFT ); }
Hi Hartman
Could you help to take this patch?
Thanks.
Kai
Greg KH
maintainerQuoted 80 lines · yekai(A)
Quoted 66 lines · Kai Ye
Use the
sysfs_emitto replace sprintf. sprintf may cause output defect in sysfs content, it is better to use new addedsysfs_emitfunction which knows the size of the temporary buffer.Signed-off-by Kai Ye <[email protected]>---
changesv1->v2:
modfiy the comments.
changesv2->v3:
modify the "changes" lines.drivers/misc/uacce/uacce.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/misc/uacce/uacce.c +5
-5@@ -289,7 +289,7 @@ static ssize_t api_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->api_ver); +return sysfs_emit (buf,"%s\n" , uacce->api_ver); } static ssize_t flags_show(struct device *dev,@@ -297,7 +297,7 @@ static ssize_t flags_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%u\n" , uacce->flags); +return sysfs_emit (buf,"%u\n" , uacce->flags); } static ssize_t available_instances_show(struct device *dev,@@ -309,7 +309,7 @@ static ssize_t available_instances_show(struct device *dev,if (!uacce->ops->get_available_instances)return -ENODEV ; -return sprintf (buf,"%d\n" , +return sysfs_emit (buf,"%d\n" , uacce->ops->get_available_instances (uacce)); }@@ -318,7 +318,7 @@ static ssize_t algorithms_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%s\n" , uacce->algs); +return sysfs_emit (buf,"%s\n" , uacce->algs); } static ssize_t region_mmio_size_show(struct device *dev,@@ -326,7 +326,7 @@ static ssize_t region_mmio_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_MMIO ] <<PAGE_SHIFT ); }drivers/misc/uacce/uacce.c static ssize_t region_dus_size_show(struct device *dev, · line 341
Quoted 8 lines
drivers/misc/uacce/uacce.c +1
-1@@ -335,7 +335,7 @@ static ssize_t region_dus_size_show(struct device *dev, {struct uacce_device *uacce =to_uacce_device (dev); -return sprintf (buf,"%lu\n" , +return sysfs_emit (buf,"%lu\n" , uacce->qf_pg_num[UACCE_QFRT_DUS ] <<PAGE_SHIFT ); }Hi Hartman
Quoted 1 line
Could you help to take this patch?
It has only been 1 week. It is in my "to review" queue, please be patient. Patches that actually fix things and are new features are always a higher priority than changes like this that have no functional change at all.
thanks,
greg k-h