From: 王擎 <wangqing@vivo.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: 回复: [PATCH] usb: replace snprintf in show functions with sysfs_emit
Date: Wed, 13 Oct 2021 06:52:53 +0000 [thread overview]
Message-ID: <SL2PR06MB3082C1AAF2A11871C10CDA53BDB79@SL2PR06MB3082.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <AA2A8gBxEnrQndzc*evdgarV.9.1634105950804.Hmail.wangqing@vivo.com>
>> On Tue, Oct 12, 2021 at 08:27:47PM -0700, Qing Wang wrote:
>> coccicheck complains about the use of snprintf() in sysfs show functions.
>>
>> Fix the following coccicheck warning:
>> drivers/usb/core/sysfs.c:730:8-16: WARNING: use scnprintf or sprintf.
>> drivers/usb/core/sysfs.c:921:8-16: WARNING: use scnprintf or sprintf.
>>
>> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>>
>> Signed-off-by: Qing Wang <wangqing@vivo.com>
>> ---
>> drivers/usb/core/sysfs.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
>> index fa2e49d..6387c0d 100644
>> --- a/drivers/usb/core/sysfs.c
>> +++ b/drivers/usb/core/sysfs.c
>> @@ -727,7 +727,7 @@ static ssize_t authorized_show(struct device *dev,
>> struct device_attribute *attr, char *buf)
>> {
>> struct usb_device *usb_dev = to_usb_device(dev);
>> - return snprintf(buf, PAGE_SIZE, "%u\n", usb_dev->authorized);
>> + return sysfs_emit(buf, "%u\n", usb_dev->authorized);
>> }
>>
>> /*
>> @@ -918,7 +918,7 @@ static ssize_t authorized_default_show(struct device *dev,
>> struct usb_hcd *hcd;
>>
>> hcd = bus_to_hcd(usb_bus);
>> - return snprintf(buf, PAGE_SIZE, "%u\n", hcd->dev_policy);
>> + return sysfs_emit(buf, "%u\n", hcd->dev_policy);
>> }
>>
>> static ssize_t authorized_default_store(struct device *dev,
>> --
>> 2.7.4
>>
>
> If you are going to change this file, you should do this for all of the
> sysfs show functions in this file, not just 2 of them, right? Please
> change this patch to do that.
>
> thanks,
>
> greg k-h
Only these 2 snprintf need to be modified, other show functions
used sprintf do not need to modify.
Thanks,
Qing
next prev parent reply other threads:[~2021-10-13 6:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 3:27 Qing Wang
2021-10-13 6:19 ` Greg Kroah-Hartman
[not found] ` <AA2A8gBxEnrQndzc*evdgarV.9.1634105950804.Hmail.wangqing@vivo.com>
2021-10-13 6:52 ` 王擎 [this message]
2021-10-13 7:07 ` 回复: " Greg Kroah-Hartman
[not found] ` <AGUA7ADTEv9Q*f-TXCLIpKpn.9.1634108876473.Hmail.wangqing@vivo.com>
2021-10-13 7:20 ` 回复: " 王擎
2021-10-13 7:28 ` Greg Kroah-Hartman
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=SL2PR06MB3082C1AAF2A11871C10CDA53BDB79@SL2PR06MB3082.apcprd06.prod.outlook.com \
--to=wangqing@vivo.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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®