Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp924911rwb; Thu, 18 Aug 2022 15:03:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR40MIWiIYsu4PXBjfjX2LuMp7esqqc1YUH7IKuyNCNP+K7kGwP1mNQTv/8f6p8csml8PhSU X-Received: by 2002:a63:6b05:0:b0:41c:2216:d2b2 with SMTP id g5-20020a636b05000000b0041c2216d2b2mr3994851pgc.118.1660860201632; Thu, 18 Aug 2022 15:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660860201; cv=none; d=google.com; s=arc-20160816; b=mUH7uzt1jFNi+31l/oZpeabSZK7HHFhGW2j2pjO+tFfmXhhAdYf37nqmRzrKQStnLR X6+Wg+c9zvzYVDG0sf4oA/Y6WXYMoPggjAIf0Z8VfiYERn+IKmM8IG3wASdPDXoDL6+f R5mXKTB4dSLnPyp9XBrvXxMrU+zf21ysPglcpHlxVWvPHuLl/rRIqTraZh7V5N177RjD Df77b3f4tqkt0e1zJrr32dpUZDYicgoulaiWP/rtYP67doYo1Pl9ZCtud/6TFMkuD5hB pwL7paLzb54nycNCsiOrGytOamFE3WihFVyDZ0WIJOgp5nPVTrYOq8T+2jyihSmNOut/ 9i2w== 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=8a0Ql4h9cHO1zReEtbOgsykaxHWHUoBmz+EsDr8t0U4=; b=Lt4vrPQFtf7MNgQKu/Z5NIXWG7nazhirzIXBRdACxHlGXZARv+7e7JGkluv+uZadzH Cmp1pc0TOaRLs+/QaFQGzXDkVbcEQKcXghWZ+49tzKXtHAHzYJuZOnp0Rv/zZfw1hVt0 dlOYrtM9/eN5SU0enPplhyS/NaPT2yan3tp6itxih3QANhdooY1eTQHOEn46aeKrmBwb IAcKt4DfwVWkE15CYsrtlrIMFypUFp499h+3hN7X9FsPDsuz+R5EncBhqJsq9C5BYn5h 0bxd6CzWxrBcUuD545Q8nDEVgsHnWFedc2WhO8DGPGXXB3+/P61W+wbBnxEFMUxn5Drt UbCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=3ucEsOmN; 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 m4-20020a170902db0400b00163f5028fe7si2223676plx.365.2022.08.18.15.03.10; Thu, 18 Aug 2022 15:03:21 -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=3ucEsOmN; 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 S1346308AbiHRVAz (ORCPT + 99 others); Thu, 18 Aug 2022 17:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345881AbiHRVAG (ORCPT ); Thu, 18 Aug 2022 17:00:06 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543A5D345E for ; Thu, 18 Aug 2022 14:00:01 -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=qDmf4Bsrxo6BfokqhIhswvHdmlz bGFO97gi1JjH+g84=; b=3ucEsOmN++mJRNj7FiDelgxQnlSibfh7rztOzEuGLXe SsZZjIvrf4smV4yTX+r8FnqqmWfisBc7MjGt2NKVdGkkNELc1FMgzwP9oi3vnab2 2/Vgmtq6Shz1953l38O3SRsYc2PRQddfuFKfWN7lM+gVJFVeHa0hH6RxjPg/Hrz8 = Received: (qmail 3959462 invoked from network); 18 Aug 2022 22:59:58 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 22:59:58 +0200 X-UD-Smtp-Session: l3s3148p1@Qf2lQ4rmc7Iucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Jens Axboe , Philipp Reisner , Lars Ellenberg , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Geoff Levand , Jim Paris , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Minchan Kim , Nitin Gupta , Sergey Senozhatsky , linux-block@vger.kernel.org, drbd-dev@lists.linbit.com, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] block: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 22:59:57 +0200 Message-Id: <20220818205958.6552-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/block/brd.c | 2 +- drivers/block/drbd/drbd_nl.c | 2 +- drivers/block/mtip32xx/mtip32xx.c | 12 ++++++------ drivers/block/ps3vram.c | 2 +- drivers/block/zram/zram_drv.c | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 859499cd1ff8..20acc4a1fd6d 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -397,7 +397,7 @@ static int brd_alloc(int i) disk->minors = max_part; disk->fops = &brd_fops; disk->private_data = brd; - strlcpy(disk->disk_name, buf, DISK_NAME_LEN); + strscpy(disk->disk_name, buf, DISK_NAME_LEN); set_capacity(disk, rd_size * 2); /* diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 013d355a2033..864c98e74875 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -4752,7 +4752,7 @@ void notify_helper(enum drbd_notification_type type, struct drbd_genlmsghdr *dh; int err; - strlcpy(helper_info.helper_name, name, sizeof(helper_info.helper_name)); + strscpy(helper_info.helper_name, name, sizeof(helper_info.helper_name)); helper_info.helper_name_len = min(strlen(name), sizeof(helper_info.helper_name)); helper_info.helper_status = status; diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 562725d222a7..815d77ba6381 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -1397,15 +1397,15 @@ static void mtip_dump_identify(struct mtip_port *port) if (!port->identify_valid) return; - strlcpy(cbuf, (char *)(port->identify+10), 21); + strscpy(cbuf, (char *)(port->identify + 10), 21); dev_info(&port->dd->pdev->dev, "Serial No.: %s\n", cbuf); - strlcpy(cbuf, (char *)(port->identify+23), 9); + strscpy(cbuf, (char *)(port->identify + 23), 9); dev_info(&port->dd->pdev->dev, "Firmware Ver.: %s\n", cbuf); - strlcpy(cbuf, (char *)(port->identify+27), 41); + strscpy(cbuf, (char *)(port->identify + 27), 41); dev_info(&port->dd->pdev->dev, "Model: %s\n", cbuf); dev_info(&port->dd->pdev->dev, "Security: %04x %s\n", @@ -1421,13 +1421,13 @@ static void mtip_dump_identify(struct mtip_port *port) pci_read_config_word(port->dd->pdev, PCI_REVISION_ID, &revid); switch (revid & 0xFF) { case 0x1: - strlcpy(cbuf, "A0", 3); + strscpy(cbuf, "A0", 3); break; case 0x3: - strlcpy(cbuf, "A2", 3); + strscpy(cbuf, "A2", 3); break; default: - strlcpy(cbuf, "?", 2); + strscpy(cbuf, "?", 2); break; } dev_info(&port->dd->pdev->dev, diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index e1d080f680ed..c76e0148eada 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -745,7 +745,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev) gendisk->flags |= GENHD_FL_NO_PART; gendisk->fops = &ps3vram_fops; gendisk->private_data = dev; - strlcpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name)); + strscpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name)); set_capacity(gendisk, priv->size >> 9); blk_queue_max_segments(gendisk->queue, BLK_MAX_SEGMENTS); blk_queue_max_segment_size(gendisk->queue, BLK_MAX_SEGMENT_SIZE); diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 92cb929a45b7..be435304af29 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -499,7 +499,7 @@ static ssize_t backing_dev_store(struct device *dev, goto out; } - strlcpy(file_name, buf, PATH_MAX); + strscpy(file_name, buf, PATH_MAX); /* ignore trailing newline */ sz = strlen(file_name); if (sz > 0 && file_name[sz - 1] == '\n') @@ -1031,7 +1031,7 @@ static ssize_t comp_algorithm_store(struct device *dev, char compressor[ARRAY_SIZE(zram->compressor)]; size_t sz; - strlcpy(compressor, buf, sizeof(compressor)); + strscpy(compressor, buf, sizeof(compressor)); /* ignore trailing newline */ sz = strlen(compressor); if (sz > 0 && compressor[sz - 1] == '\n') @@ -1952,7 +1952,7 @@ static int zram_add(void) if (ret) goto out_cleanup_disk; - strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); + strscpy(zram->compressor, default_compressor, sizeof(zram->compressor)); zram_debugfs_register(zram); pr_info("Added device: %s\n", zram->disk->disk_name); -- 2.35.1