From: Greg KH <gregkh@linuxfoundation.org>
To: davidcomponentone@gmail.com
Cc: bhelgaas@google.com, yang.guang5@zte.com.cn, rajatja@google.com,
Thinh.Nguyen@synopsys.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] usb: core: replace snprintf with sysfs_emit
Date: Thu, 27 Jan 2022 07:22:58 +0100 [thread overview]
Message-ID: <YfI6Qj+oIsNQYPJ2@kroah.com> (raw)
In-Reply-To: <e205c334a8c65c03702a94ee382ec488bcc1d019.1643183299.git.yang.guang5@zte.com.cn>
On Thu, Jan 27, 2022 at 07:54:54AM +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
>
> coccinelle report:
> ./drivers/usb/core/sysfs.c:921:8-16:
> WARNING: use scnprintf or sprintf
> ./drivers/usb/core/sysfs.c:730:8-16:
> WARNING: use scnprintf or sprintf
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
Again, no, this did not report this. I'll keep ignoring changes like
this that get this wrong.
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> Signed-off-by: David Yang <davidcomponentone@gmail.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 fa2e49d432ff..6387c0dfe30e 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.30.2
>
Also this change is not correct, why are you only doing this for 2 sysfs
files and not all of them? Is there anything incorrect about the
current sysfs handling in this file that requires them to be changed to
use the new api?
greg k-h
prev parent reply other threads:[~2022-01-27 6:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 23:54 [PATCH] usb: core: replace snprintf with sysfs_emit davidcomponentone
2022-01-27 6:22 ` Greg KH [this message]
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=YfI6Qj+oIsNQYPJ2@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=Thinh.Nguyen@synopsys.com \
--cc=bhelgaas@google.com \
--cc=davidcomponentone@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rajatja@google.com \
--cc=yang.guang5@zte.com.cn \
--cc=zealci@zte.com.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.