From: Joe Perches <joe@perches.com>
To: Kai Ye <yekai13@huawei.com>,
gregkh@linuxfoundation.org, linux-accelerators@lists.ozlabs.org,
linux-kernel@vger.kernel.org, linuxarm@huawei.com,
zhangfei.gao@linaro.org, wangzhou1@hisilicon.com
Subject: Re: [PATCH v2] uacce: use sysfs_emit instead of sprintf
Date: Sun, 05 Dec 2021 23:18:27 -0800 [thread overview]
Message-ID: <c9e11594e7edbbf8ee0a01a5009457a2c4a79ffc.camel@perches.com> (raw)
In-Reply-To: <20211206070943.45971-1-yekai13@huawei.com>
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...
next prev parent reply other threads:[~2021-12-06 7:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 7:09 Kai Ye
2021-12-06 7:18 ` Joe Perches [this message]
2021-12-06 7:25 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9e11594e7edbbf8ee0a01a5009457a2c4a79ffc.camel@perches.com \
--to=joe@perches.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-accelerators@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=yekai13@huawei.com \
--cc=zhangfei.gao@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®