lkml.org 
[lkml]   [2021]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] usb: replace snprintf in show functions with sysfs_emit
Date
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
\
 
 \ /
  Last update: 2021-10-13 05:28    [W:0.052 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site