Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp929026rwb; Thu, 18 Aug 2022 15:07:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR6oqF4xgGZKJQysMNHCdv3dze1Q5qffsX+ez93thVfCypeEmr6uekVtYisRXNWZN5az9cm9 X-Received: by 2002:a05:6402:3495:b0:43d:d76e:e9ff with SMTP id v21-20020a056402349500b0043dd76ee9ffmr3797703edc.227.1660860438948; Thu, 18 Aug 2022 15:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660860438; cv=none; d=google.com; s=arc-20160816; b=SVIdHhIC3s6AmPv+Pz8W2xMNLsfK9Eso8SrKghfXNQYLIs0tB1SVjeZCzks0NMYtmC UNQsvN7XXpY0TTqa9NT8UvaURsmMGE+ePQFyyor+slRvCTmbh95sxIoKtR+UownYafxU YUy+dYL7z82i/2HenjtRCs/aZ/d2+UxbY5ZUjiBhIvJ3QqeLvVZJqKEBxBxHa6/vLmDY sj/NxrEfQiEr4XBfEqJp8BsXSaJsbKX0eHirEl2yeCXBUB7fZ3ddJ81VBlKLN4bDfYJU UFMOHbXZZtl7LNfM8qKKHQYG8dXTfRIZ1V8oVemJh7adw7n8gQ29BfEycFipYV4X8ohO Agww== 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=s5eI3SDTdfCC7fNbM2s5TmNOUCZ/Dkt5YtJgUJk18oA=; b=EsFWVdAuav52g8GhiHTK1DDCue+N7EtgCkC1Jovkw8O1pVB5ODyXZ1A9o4RtxFDfA9 BptgRaBaazi9LN/6KO3agZZx8Dc+z9MOv3Mp+Juhr7FkAEOUlwazupnkWd7uzrPDtNm9 /nDkY0onSlA56oIEGf+hlkAQDINd55Af0WfPzexqGID815CNZ0MTAF/aMQDyj6L5pfIs ZWUMTN5bJU5nzhfbMIeCMsWSO/Fsc4/TiG43nQ2i+eNuXIL1nZSD7Yc/xOY4Qe096cQR hs8IoYgkJVckhDJIjKzReIqVoDSVUZE/qt+PjQcqm313JzOHvRmQS1qxsBTBmusGXfKd y6ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=Q81xMVeS; 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 w11-20020a1709064a0b00b0072a51fa07a2si1634909eju.296.2022.08.18.15.06.52; Thu, 18 Aug 2022 15:07:18 -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=Q81xMVeS; 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 S1346481AbiHRVCh (ORCPT + 99 others); Thu, 18 Aug 2022 17:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346203AbiHRVA5 (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 CF0C7D3E7D for ; Thu, 18 Aug 2022 14:00:32 -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=t65pDCnGnoh4YuAC0bcg18YMcxC Scyc0kBucHooluKE=; b=Q81xMVeS4ga6c9O6LLC122bu6xs7Dq8BI/gGi9adOwN /JwVXdC3uEfpZpo4B9vdoVMRsDA5vChGa4F5zB58Q1PN9cXpqRKF8K6QsHjKaL/H hlkMz3EEhJ+9unfR8k38+B38vB4zGBA6kafcOzJW2c7jJI5FRCt15pZjr+FfhlEQ = Received: (qmail 3960514 invoked from network); 18 Aug 2022 23:00:28 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:00:28 +0200 X-UD-Smtp-Session: l3s3148p1@ONFiRYrmlucucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Song Liu , linux-raid@vger.kernel.org Subject: [PATCH] md: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:00:27 +0200 Message-Id: <20220818210027.6964-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/md/dm-ioctl.c | 4 ++-- drivers/md/md.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 98976aaa9db9..6148fb73ccb4 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -921,9 +921,9 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) * Sneakily write in both the name and the uuid * while we have the cell. */ - strlcpy(param->name, hc->name, sizeof(param->name)); + strscpy(param->name, hc->name, sizeof(param->name)); if (hc->uuid) - strlcpy(param->uuid, hc->uuid, sizeof(param->uuid)); + strscpy(param->uuid, hc->uuid, sizeof(param->uuid)); else param->uuid[0] = '\0'; diff --git a/drivers/md/md.c b/drivers/md/md.c index afaf36b2f6ab..4d019ac0a549 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5743,7 +5743,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp) len--; if (len >= DISK_NAME_LEN) return -E2BIG; - strscpy(buf, val, len+1); + strscpy(buf, val, len + 1); if (strncmp(buf, "md_", 3) == 0) return md_alloc_and_put(0, buf); if (strncmp(buf, "md", 2) == 0 && -- 2.35.1