HID: move from strlcpy with unused retval to strscpy
Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
8272a51d82
commit
eeeec27d68
@ -246,7 +246,7 @@ static int steam_get_serial(struct steam_device *steam)
|
||||
if (reply[0] != 0xae || reply[1] != 0x15 || reply[2] != 0x01)
|
||||
return -EIO;
|
||||
reply[3 + STEAM_SERIAL_LEN] = 0;
|
||||
strlcpy(steam->serial_no, reply + 3, sizeof(steam->serial_no));
|
||||
strscpy(steam->serial_no, reply + 3, sizeof(steam->serial_no));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ static int steam_register(struct steam_device *steam)
|
||||
*/
|
||||
mutex_lock(&steam->mutex);
|
||||
if (steam_get_serial(steam) < 0)
|
||||
strlcpy(steam->serial_no, "XXXXXXXXXX",
|
||||
strscpy(steam->serial_no, "XXXXXXXXXX",
|
||||
sizeof(steam->serial_no));
|
||||
mutex_unlock(&steam->mutex);
|
||||
|
||||
@ -689,9 +689,9 @@ static struct hid_device *steam_create_client_hid(struct hid_device *hdev)
|
||||
client_hdev->version = hdev->version;
|
||||
client_hdev->type = hdev->type;
|
||||
client_hdev->country = hdev->country;
|
||||
strlcpy(client_hdev->name, hdev->name,
|
||||
strscpy(client_hdev->name, hdev->name,
|
||||
sizeof(client_hdev->name));
|
||||
strlcpy(client_hdev->phys, hdev->phys,
|
||||
strscpy(client_hdev->phys, hdev->phys,
|
||||
sizeof(client_hdev->phys));
|
||||
/*
|
||||
* Since we use the same device info than the real interface to
|
||||
|
@ -1036,7 +1036,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
|
||||
|
||||
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
|
||||
client->name, (u16)hid->vendor, (u16)hid->product);
|
||||
strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
|
||||
strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
|
||||
|
||||
ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
|
||||
|
||||
|
@ -1381,7 +1381,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
|
||||
hid->type = HID_TYPE_USBNONE;
|
||||
|
||||
if (dev->manufacturer)
|
||||
strlcpy(hid->name, dev->manufacturer, sizeof(hid->name));
|
||||
strscpy(hid->name, dev->manufacturer, sizeof(hid->name));
|
||||
|
||||
if (dev->product) {
|
||||
if (dev->manufacturer)
|
||||
|
@ -294,7 +294,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
|
||||
spin_lock_init(&kbd->leds_lock);
|
||||
|
||||
if (dev->manufacturer)
|
||||
strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name));
|
||||
strscpy(kbd->name, dev->manufacturer, sizeof(kbd->name));
|
||||
|
||||
if (dev->product) {
|
||||
if (dev->manufacturer)
|
||||
|
@ -142,7 +142,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
|
||||
mouse->dev = input_dev;
|
||||
|
||||
if (dev->manufacturer)
|
||||
strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
|
||||
strscpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
|
||||
|
||||
if (dev->product) {
|
||||
if (dev->manufacturer)
|
||||
|
@ -2226,7 +2226,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
|
||||
} else if (strstr(product_name, "Wacom") ||
|
||||
strstr(product_name, "wacom") ||
|
||||
strstr(product_name, "WACOM")) {
|
||||
strlcpy(name, product_name, sizeof(name));
|
||||
strscpy(name, product_name, sizeof(name));
|
||||
} else {
|
||||
snprintf(name, sizeof(name), "Wacom %s", product_name);
|
||||
}
|
||||
@ -2244,7 +2244,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
|
||||
if (name[strlen(name)-1] == ' ')
|
||||
name[strlen(name)-1] = '\0';
|
||||
} else {
|
||||
strlcpy(name, features->name, sizeof(name));
|
||||
strscpy(name, features->name, sizeof(name));
|
||||
}
|
||||
|
||||
snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s",
|
||||
@ -2509,7 +2509,7 @@ static void wacom_wireless_work(struct work_struct *work)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
strlcpy(wacom_wac->name, wacom_wac1->name,
|
||||
strscpy(wacom_wac->name, wacom_wac1->name,
|
||||
sizeof(wacom_wac->name));
|
||||
error = wacom_initialize_battery(wacom);
|
||||
if (error)
|
||||
|
Loading…
Reference in New Issue
Block a user