[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1634296054-6971-6-git-send-email-wangqing@vivo.com>
Date: Fri, 15 Oct 2021 04:07:32 -0700
From: Qing Wang <wangqing@...o.com>
To: Jiri Kosina <jikos@...nel.org>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Bruno Prémont <bonbons@...ux-vserver.org>,
Stefan Achatz <erazor_de@...rs.sourceforge.net>,
Jonathan Cameron <jic23@...nel.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org
Cc: Qing Wang <wangqing@...o.com>
Subject: [PATCH V2 5/5] hid-sony: replace snprintf in show functions with sysfs_emit
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@...o.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
Powered by blists - more mailing lists