From: kernel test robot <lkp@intel.com>
To: Denis Efremov <efremov@linux.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Julia Lawall <Julia.Lawall@lip6.fr>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org
Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
Date: Thu, 13 Aug 2020 08:56:14 +0800 [thread overview]
Message-ID: <20200813005614.GA85482@8851f5375e5a> (raw)
In-Reply-To: <202008130840.TWLDLwLA%lkp@intel.com>
From: kernel test robot <lkp@intel.com>
drivers/hid/hid-sony.c:611:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-sony.c:648:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-sony.c:660:8-16: WARNING: use scnprintf or sprintf
From Documentation/filesystems/sysfs.txt:
show() must not use snprintf() when formatting the value to be
returned to user space. If you can guarantee that an overflow
will never happen you can use sprintf() otherwise you must use
scnprintf().
Generated by: scripts/coccinelle/api/device_attr_show.cocci
Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7c2a69f610e64c8dec6a06a66e721f4ce1dd783a
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
Please take the patch only if it's a positive warning. Thanks!
hid-sony.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -608,7 +608,7 @@ static ssize_t ds4_show_poll_interval(st
struct hid_device *hdev = to_hid_device(dev);
struct sony_sc *sc = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%i\n", sc->ds4_bt_poll_interval);
+ return scnprintf(buf, PAGE_SIZE, "%i\n", sc->ds4_bt_poll_interval);
}
static ssize_t ds4_store_poll_interval(struct device *dev,
@@ -645,7 +645,7 @@ static ssize_t sony_show_firmware_versio
struct hid_device *hdev = to_hid_device(dev);
struct sony_sc *sc = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->fw_version);
+ return scnprintf(buf, PAGE_SIZE, "0x%04x\n", sc->fw_version);
}
static DEVICE_ATTR(firmware_version, 0444, sony_show_firmware_version, NULL);
@@ -657,7 +657,7 @@ static ssize_t sony_show_hardware_versio
struct hid_device *hdev = to_hid_device(dev);
struct sony_sc *sc = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->hw_version);
+ return scnprintf(buf, PAGE_SIZE, "0x%04x\n", sc->hw_version);
}
static DEVICE_ATTR(hardware_version, 0444, sony_show_hardware_version, NULL);
prev parent reply other threads:[~2020-08-13 0:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <202008130840.TWLDLwLA%lkp@intel.com>
2020-08-13 0:56 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings kernel test robot
2020-08-13 0:56 ` kernel test robot
2020-08-13 0:56 ` kernel test robot
2020-08-13 0:56 ` kernel test robot
2020-08-13 0:56 ` kernel test robot
2020-08-13 0:56 ` kernel test robot
2020-08-13 0:56 ` kernel test robot [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=20200813005614.GA85482@8851f5375e5a \
--to=lkp@intel.com \
--cc=Julia.Lawall@lip6.fr \
--cc=benjamin.tissoires@redhat.com \
--cc=efremov@linux.com \
--cc=jikos@kernel.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).