From: Qing Wang <wangqing@vivo.com>
To: "Jiri Kosina" <jikos@kernel.org>,
"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
"Bruno Prémont" <bonbons@linux-vserver.org>,
"Stefan Achatz" <erazor_de@users.sourceforge.net>,
"Jonathan Cameron" <jic23@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org
Cc: Qing Wang <wangqing@vivo.com>
Subject: [PATCH V2 5/5] hid-sony: replace snprintf in show functions with sysfs_emit
Date: Fri, 15 Oct 2021 04:07:32 -0700 [thread overview]
Message-ID: <1634296054-6971-6-git-send-email-wangqing@vivo.com> (raw)
In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com>
show() should not use snprintf() when formatting the value to be returned
to user space, snprintf() returns the length the resulting string and
scnprintf() returns the number of bytes printed into the buffer.
Fix the coccicheck warnings:
WARNING: use scnprintf or sprintf.
Use sysfs_emit() instead of scnprintf() makes more sense.
Signed-off-by: Qing Wang <wangqing@vivo.com>
---
drivers/hid/hid-sony.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index d1b107d..55423db 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -707,7 +707,7 @@ static ssize_t ds4_show_poll_interval(struct device *dev,
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 sysfs_emit(buf, "%i\n", sc->ds4_bt_poll_interval);
}
static ssize_t ds4_store_poll_interval(struct device *dev,
@@ -744,7 +744,7 @@ static ssize_t sony_show_firmware_version(struct device *dev,
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 sysfs_emit(buf, "0x%04x\n", sc->fw_version);
}
static DEVICE_ATTR(firmware_version, 0444, sony_show_firmware_version, NULL);
@@ -756,7 +756,7 @@ static ssize_t sony_show_hardware_version(struct device *dev,
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 sysfs_emit(buf, "0x%04x\n", sc->hw_version);
}
static DEVICE_ATTR(hardware_version, 0444, sony_show_hardware_version, NULL);
--
2.7.4
prev parent reply other threads:[~2021-10-15 11:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 11:07 [PATCH V2 0/5] hid: " Qing Wang
2021-10-15 11:07 ` [PATCH V2 1/5] hid-lenovo: " Qing Wang
2021-10-15 13:51 ` Jonathan Cameron
2021-10-15 11:07 ` [PATCH V2 2/5] hid-picolcd: " Qing Wang
2021-10-15 11:07 ` [PATCH V2 3/5] hid-roccat: " Qing Wang
2021-10-15 11:07 ` [PATCH V2 4/5] hid-sensor: " Qing Wang
2021-10-15 13:48 ` Jonathan Cameron
2021-10-15 11:07 ` Qing Wang [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=1634296054-6971-6-git-send-email-wangqing@vivo.com \
--to=wangqing@vivo.com \
--cc=benjamin.tissoires@redhat.com \
--cc=bonbons@linux-vserver.org \
--cc=erazor_de@users.sourceforge.net \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/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®