lkml.org 
[lkml]   [2021]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] uacce: use sysfs_emit instead of sprintf
From
Date
On Mon, 2021-12-06 at 15:09 +0800, Kai Ye wrote:
> 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.
[]
> diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
[]
> @@ -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));

It's generally good form to rewrap the multiple line statements
to the open parenthesis so the below would be better:

return sysfs_emit(buf, "%d\n",
uacce->ops->get_available_instances(uacce));

> @@ -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);

etc...


\
 
 \ /
  Last update: 2021-12-06 08:19    [W:0.050 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site