From: Rasmus Villemoes Date: Sat, 14 Nov 2015 21:08:08 +0000 (+0100) Subject: HID: core: use scnprintf in modalias_show() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dfa0c5faf1b8964fa508373232b4cb597a5c226b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git HID: core: use scnprintf in modalias_show() scnprintf() exists to provide these semantics, so we might as well use it. Signed-off-by: Rasmus Villemoes Signed-off-by: Jiri Kosina --- diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index d5ddb7573691..3c1cfc6d9964 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2217,12 +2217,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);