Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp912181rwb; Thu, 18 Aug 2022 14:46:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dMB7tXeBLPRrPVBobOuLTy7JTmZw7f7PEsaZBQks1TsUh9EaTeFZJzy4YHT+gUNiB3Slw X-Received: by 2002:a17:90b:388f:b0:1f5:7748:9667 with SMTP id mu15-20020a17090b388f00b001f577489667mr10746530pjb.158.1660859175630; Thu, 18 Aug 2022 14:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660859175; cv=none; d=google.com; s=arc-20160816; b=SJF2bKeL21XzkVjaI5lgC5XcPfL/nU7/+1Ay0pNMu+++MZ+FJyXyY+5Bvqntj2wh2j c2RjScRez2gTqFbBX/qKKrNp4yDuehoBin15w+POzam8Ri/jPkrzcNbfXJiMcEZiMaeS qM0rpDAyryecCgICeXScO6K1+aIKkjmMHNqsmtz8Y8SofJhtFS2qSkjZo8BXZQr8HGLZ 2EbyTGt2BEZJ7WLVgwMYsDVGa2lEK1aixxoHp2PmNpzXk5FDduEwz3P31WLbK2QBEjhA 7dJLh8fOjIIdRpyIxIXu9T5NR2P0BI2IM1VCdXlsBiyENwpy6bkpWby7ggLx/1gCaU37 pp+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XtZMZ/bk/vzzu9S2F3jH5VxHSq0rZIH3Jj02fz8XTbc=; b=aRf5ugn2lgXpZZt28QWBdeKYSkOuG5Rk16EWOgxpG7fSIDqRmgvXj71m+o24QMRIS1 rp9amHcJb5GWiEMQrWfw4BMAxJ/WC+SH5xtRrJGSKv/v6Iml3flGVunZfpNccrUqWwiU CpDOmfQZJ7vj9ItP5bbEVNsRi9Ttv3R+44dx2oaZXVcIeitUnpjcZMd4JVXmYqU8JqRb OsjzwKHv0J986o8Ze548+5jK7vyhHnoGFzQw7pMxc9cvlabNEF0/j46Sg9Nqr8PlDCd8 4ganrlpTpPtHM7odoe+qxzt9W7M+DxdtRO0SPNE1iwKWPQWkckyrKGKgjw2DfSD4J8u0 DT6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b="VBFD/YmC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a056a00218b00b0052e3d468e9esi2529131pfi.369.2022.08.18.14.46.04; Thu, 18 Aug 2022 14:46:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b="VBFD/YmC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346383AbiHRVBh (ORCPT + 99 others); Thu, 18 Aug 2022 17:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346284AbiHRVAm (ORCPT ); Thu, 18 Aug 2022 17:00:42 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89A7CD3989 for ; Thu, 18 Aug 2022 14:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=dxPXuV6VeCxHx96vosgf4BR2smZ L5nHKKB2D/6luVfo=; b=VBFD/YmCgvoVhwLb0SzKbbVUneB65FqvX1pfIgHt3gC tOh4K9Axr7CmaF8w3qHEENxXnmesbdw/M1rvYndhAwdcOdbdzMck7lbrHjJNzT7m d8YctR6xD/Tm4LY2ERtRhjpJrrm+svYpoFq6nH0bIql1jwekmgRI2x46WUsTgasM = Received: (qmail 3959956 invoked from network); 18 Aug 2022 23:00:10 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:00:10 +0200 X-UD-Smtp-Session: l3s3148p1@ruFZRIrmuNgucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Jiri Kosina , Benjamin Tissoires , Ping Cheng , Jason Gerecke , linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH] HID: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:00:09 +0200 Message-Id: <20220818210010.6745-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/hid/hid-steam.c | 8 ++++---- drivers/hid/i2c-hid/i2c-hid-core.c | 2 +- drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- drivers/hid/wacom_sys.c | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c index a3b151b29bd7..f675e1aa08c9 100644 --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -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 diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index c078f09a2318..347c80ec6fff 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -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); diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 4490e2f7252a..be4c731aaa65 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -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) diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index b4b007c4beb6..c439ed2f16db 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c @@ -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) diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index fb1d7d1f6999..3fd93c2e4f4a 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c @@ -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) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 194a2e327591..102302e9afd9 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -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) -- 2.35.1