Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp929091rwb; Thu, 18 Aug 2022 15:07:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+AOxKcNhIljdjNh5psF8yKX2RcIbEOTD9OArqDfIBkOD0imfmNXQssZfx6nWm1Zasn78m X-Received: by 2002:a17:907:a074:b0:730:c7a3:2c9 with SMTP id ia20-20020a170907a07400b00730c7a302c9mr2997569ejc.110.1660860442338; Thu, 18 Aug 2022 15:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660860442; cv=none; d=google.com; s=arc-20160816; b=KLbeMKlUB/naNM8F6Kac/ObHKdjzq9wh9y6nrHIhb8VSzWIcGzjdib3D3B0i2+CYbS IPHpPgikgGHaGeA3x3kXipgMFutJbT3C7V2FRzSXpWanW5ig2Hy9LsOw09c3hMAGhUiq hSHdYd6Bt/EF2S/op/jP2aCyATu/vC23DQSIdSqNzhm38tWuLa2FKBTqSpBo6T8MqCOe YDADFU5JCAgF5kSdTOI6MyI+1k/CZLGUcahhdqNHFamsbEj9wanD8UKq/k3uvtWIbZqf NMT9EbfbLWY3CWfbsIYAD+afjXXjzG8kligAEZ4KlQ2tQ6JrtX3UR338UHxn0I4IHPpX 915w== 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=GIUGUEtwFsmXkLFF6+Hk+08rDZilq0sv/FApM3mkeug=; b=qtJwfephlf4hYnCrAWpvwHdwNztC/BIjIpbuGejuovr9I+/hos/8MXoiLUoX3uynk0 +30/7u4fGZKv0FHpnHETDKFvF19DLKgIGw5E0Cq0sNV6eD6lZhhqdF5WYz1rqf1J/4zF uU7q3r87sG1Gc5QRlLiU21QL/KpzTuzlCb/DPDpPvg+QC2VOe9vtX+finfnz/qnhQpK7 7FvETASy9Lz9DKrpYZvhko/4rkAJ0qWEd+vXt5iA7EjdC53i0Xez0rgxk+vnWkKJ4+vg 2m46rgf/ZXxLsx7ArPhGJQlZF373rDHAMPnj5d097pxTGQ1bxWt6lVjIo0gc7NlqkaFj X3kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=gx+ljJX5; 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 cs14-20020a0564020c4e00b004407104243csi1798400edb.153.2022.08.18.15.06.56; Thu, 18 Aug 2022 15:07:22 -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=gx+ljJX5; 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 S1345681AbiHRVB7 (ORCPT + 99 others); Thu, 18 Aug 2022 17:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346300AbiHRVAy (ORCPT ); Thu, 18 Aug 2022 17:00:54 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B56D39B0 for ; Thu, 18 Aug 2022 14:00:23 -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=2QMyQigqupjEi14GAS45NlzrLyU hyLireoXcynH4Uh4=; b=gx+ljJX5oCKjcl/a7DB2Q22vYw4z4G/kIrSrJNc+CXI 29lApFaopCKN0uJGBD49YzJ6GDj9Ulhbb9qFzi8G/SaF9D+qtAZzZtEiJ0r/bn52 0jfaDh7rLDlAzm6cLxobfcQ1HS9iLwj+8L+Vs/X5UM6/Bi6MAS+smuLXQ2ThzFJM = Received: (qmail 3960180 invoked from network); 18 Aug 2022 23:00:17 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:00:17 +0200 X-UD-Smtp-Session: l3s3148p1@abHGRIrm7doucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org Subject: [PATCH] iio: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:00:16 +0200 Message-Id: <20220818210017.6817-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/iio/common/st_sensors/st_sensors_core.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 9910ba1da085..35720c64fea8 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -354,7 +354,7 @@ void st_sensors_dev_name_probe(struct device *dev, char *name, int len) return; /* The name from the match takes precedence if present */ - strlcpy(name, match, len); + strscpy(name, match, len); } EXPORT_SYMBOL_NS(st_sensors_dev_name_probe, IIO_ST_SENSORS); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c index 9b4298095d3f..f7bce428d9eb 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c @@ -65,7 +65,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev, sub_elem = &elem->package.elements[j]; if (sub_elem->type == ACPI_TYPE_STRING) - strlcpy(info->type, sub_elem->string.pointer, + strscpy(info->type, sub_elem->string.pointer, sizeof(info->type)); else if (sub_elem->type == ACPI_TYPE_INTEGER) { if (sub_elem->integer.value != client->addr) { @@ -158,7 +158,7 @@ int inv_mpu_acpi_create_mux_client(struct i2c_client *client) char *name; info.addr = secondary; - strlcpy(info.type, dev_name(&adev->dev), + strscpy(info.type, dev_name(&adev->dev), sizeof(info.type)); name = strchr(info.type, ':'); if (name) -- 2.35.1