Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wolfram Sang and committed by
Jiri Kosina
eeeec27d 8272a51d

+11 -11
+4 -4
drivers/hid/hid-steam.c
··· 246 246 if (reply[0] != 0xae || reply[1] != 0x15 || reply[2] != 0x01) 247 247 return -EIO; 248 248 reply[3 + STEAM_SERIAL_LEN] = 0; 249 - strlcpy(steam->serial_no, reply + 3, sizeof(steam->serial_no)); 249 + strscpy(steam->serial_no, reply + 3, sizeof(steam->serial_no)); 250 250 return 0; 251 251 } 252 252 ··· 514 514 */ 515 515 mutex_lock(&steam->mutex); 516 516 if (steam_get_serial(steam) < 0) 517 - strlcpy(steam->serial_no, "XXXXXXXXXX", 517 + strscpy(steam->serial_no, "XXXXXXXXXX", 518 518 sizeof(steam->serial_no)); 519 519 mutex_unlock(&steam->mutex); 520 520 ··· 689 689 client_hdev->version = hdev->version; 690 690 client_hdev->type = hdev->type; 691 691 client_hdev->country = hdev->country; 692 - strlcpy(client_hdev->name, hdev->name, 692 + strscpy(client_hdev->name, hdev->name, 693 693 sizeof(client_hdev->name)); 694 - strlcpy(client_hdev->phys, hdev->phys, 694 + strscpy(client_hdev->phys, hdev->phys, 695 695 sizeof(client_hdev->phys)); 696 696 /* 697 697 * Since we use the same device info than the real interface to
+1 -1
drivers/hid/i2c-hid/i2c-hid-core.c
··· 1036 1036 1037 1037 snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", 1038 1038 client->name, (u16)hid->vendor, (u16)hid->product); 1039 - strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); 1039 + strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); 1040 1040 1041 1041 ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); 1042 1042
+1 -1
drivers/hid/usbhid/hid-core.c
··· 1381 1381 hid->type = HID_TYPE_USBNONE; 1382 1382 1383 1383 if (dev->manufacturer) 1384 - strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); 1384 + strscpy(hid->name, dev->manufacturer, sizeof(hid->name)); 1385 1385 1386 1386 if (dev->product) { 1387 1387 if (dev->manufacturer)
+1 -1
drivers/hid/usbhid/usbkbd.c
··· 294 294 spin_lock_init(&kbd->leds_lock); 295 295 296 296 if (dev->manufacturer) 297 - strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); 297 + strscpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); 298 298 299 299 if (dev->product) { 300 300 if (dev->manufacturer)
+1 -1
drivers/hid/usbhid/usbmouse.c
··· 142 142 mouse->dev = input_dev; 143 143 144 144 if (dev->manufacturer) 145 - strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); 145 + strscpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); 146 146 147 147 if (dev->product) { 148 148 if (dev->manufacturer)
+3 -3
drivers/hid/wacom_sys.c
··· 2226 2226 } else if (strstr(product_name, "Wacom") || 2227 2227 strstr(product_name, "wacom") || 2228 2228 strstr(product_name, "WACOM")) { 2229 - strlcpy(name, product_name, sizeof(name)); 2229 + strscpy(name, product_name, sizeof(name)); 2230 2230 } else { 2231 2231 snprintf(name, sizeof(name), "Wacom %s", product_name); 2232 2232 } ··· 2244 2244 if (name[strlen(name)-1] == ' ') 2245 2245 name[strlen(name)-1] = '\0'; 2246 2246 } else { 2247 - strlcpy(name, features->name, sizeof(name)); 2247 + strscpy(name, features->name, sizeof(name)); 2248 2248 } 2249 2249 2250 2250 snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s", ··· 2509 2509 goto fail; 2510 2510 } 2511 2511 2512 - strlcpy(wacom_wac->name, wacom_wac1->name, 2512 + strscpy(wacom_wac->name, wacom_wac1->name, 2513 2513 sizeof(wacom_wac->name)); 2514 2514 error = wacom_initialize_battery(wacom); 2515 2515 if (error)