diff mbox

HID: core: use scnprintf in modalias_show()

Message ID 1447535288-12523-1-git-send-email-linux@rasmusvillemoes.dk (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Rasmus Villemoes Nov. 14, 2015, 9:08 p.m. UTC
scnprintf() exists to provide these semantics, so we might as well use
it.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/hid/hid-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Jiri Kosina Nov. 20, 2015, 9:48 a.m. UTC | #1
On Sat, 14 Nov 2015, Rasmus Villemoes wrote:

> scnprintf() exists to provide these semantics, so we might as well use
> it.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Applied to hid.git#for-4.5/core. Thanks,
diff mbox

Patch

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c6f7a694f67a..efa3660e23a0 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2223,12 +2223,9 @@  static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
 			     char *buf)
 {
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
-	int len;
-
-	len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
-		       hdev->bus, hdev->group, hdev->vendor, hdev->product);
 
-	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+	return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
+			 hdev->bus, hdev->group, hdev->vendor, hdev->product);
 }
 static DEVICE_ATTR_RO(modalias);