From patchwork Thu Aug 18 21:00:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 598349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB658C00140 for ; Thu, 18 Aug 2022 21:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346333AbiHRVCH (ORCPT ); Thu, 18 Aug 2022 17:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346331AbiHRVA5 (ORCPT ); Thu, 18 Aug 2022 17:00:57 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F75D3E75 for ; Thu, 18 Aug 2022 14:00:31 -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=q+7y6OO7vVpB9j8AWpzNjTa7QMG hKSJ4rMcNs5QyAj8=; b=t6Vsp/lqsc8ar7L3hg5WYioOft7sYUqst/jlAz8UUXL SKUkvNcYe76Y42aNiXBFIUzn8PT+RuGHzbCnJQutnZQazycNcQt8C+msv4xntPtb TmeiB61L4JORPEf+rQHOj2PcLWEgJd0wjxRfukdtYszNgwwVe+U6eXKVSIqMayO4 = Received: (qmail 3960437 invoked from network); 18 Aug 2022 23:00:25 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:00:25 +0200 X-UD-Smtp-Session: l3s3148p1@kBs9RYrmlPQucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Pavel Machek , Sakari Ailus , Jan-Simon Moeller , linux-leds@vger.kernel.org Subject: [PATCH] leds: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:00:24 +0200 Message-Id: <20220818210024.6913-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Acked-by: Sakari Ailus (as3645a) Reviewed-by: Sakari Ailus --- drivers/leds/flash/leds-aat1290.c | 2 +- drivers/leds/flash/leds-as3645a.c | 4 ++-- drivers/leds/led-class.c | 2 +- drivers/leds/leds-blinkm.c | 2 +- drivers/leds/leds-spi-byte.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/leds/flash/leds-aat1290.c b/drivers/leds/flash/leds-aat1290.c index 589484b22c79..f12ecb2c6580 100644 --- a/drivers/leds/flash/leds-aat1290.c +++ b/drivers/leds/flash/leds-aat1290.c @@ -425,7 +425,7 @@ static void aat1290_init_v4l2_flash_config(struct aat1290_led *led, struct led_classdev *led_cdev = &led->fled_cdev.led_cdev; struct led_flash_setting *s; - strlcpy(v4l2_sd_cfg->dev_name, led_cdev->dev->kobj.name, + strscpy(v4l2_sd_cfg->dev_name, led_cdev->dev->kobj.name, sizeof(v4l2_sd_cfg->dev_name)); s = &v4l2_sd_cfg->intensity; diff --git a/drivers/leds/flash/leds-as3645a.c b/drivers/leds/flash/leds-as3645a.c index aa3f82be0a9c..570c5cdfb611 100644 --- a/drivers/leds/flash/leds-as3645a.c +++ b/drivers/leds/flash/leds-as3645a.c @@ -651,8 +651,8 @@ static int as3645a_v4l2_setup(struct as3645a *flash) }, }; - strlcpy(cfg.dev_name, led->dev->kobj.name, sizeof(cfg.dev_name)); - strlcpy(cfgind.dev_name, flash->iled_cdev.dev->kobj.name, + strscpy(cfg.dev_name, led->dev->kobj.name, sizeof(cfg.dev_name)); + strscpy(cfgind.dev_name, flash->iled_cdev.dev->kobj.name, sizeof(cfgind.dev_name)); flash->vf = v4l2_flash_init( diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 6a8ea94834fa..71b47c081b37 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -310,7 +310,7 @@ static int led_classdev_next_name(const char *init_name, char *name, int ret = 0; struct device *dev; - strlcpy(name, init_name, len); + strscpy(name, init_name, len); while ((ret < len) && (dev = class_find_device_by_name(leds_class, name))) { diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index bd7d0d5cf3b6..883f39e17f2f 100644 --- a/drivers/leds/leds-blinkm.c +++ b/drivers/leds/leds-blinkm.c @@ -561,7 +561,7 @@ static int blinkm_detect(struct i2c_client *client, struct i2c_board_info *info) return -ENODEV; } - strlcpy(info->type, "blinkm", I2C_NAME_SIZE); + strscpy(info->type, "blinkm", I2C_NAME_SIZE); return 0; } diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 2bc5c99daf51..2c7ffc3c78e6 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -98,7 +98,7 @@ static int spi_byte_probe(struct spi_device *spi) return -ENOMEM; of_property_read_string(child, "label", &name); - strlcpy(led->name, name, sizeof(led->name)); + strscpy(led->name, name, sizeof(led->name)); led->spi = spi; mutex_init(&led->mutex); led->cdef = device_get_match_data(dev);