From patchwork Thu Aug 18 21:00:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12947909 X-Patchwork-Delegate: song@kernel.org 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 36256C3F6B0 for ; Thu, 18 Aug 2022 21:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346441AbiHRVCH (ORCPT ); Thu, 18 Aug 2022 17:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346334AbiHRVA5 (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 6A15ED3E67 for ; Thu, 18 Aug 2022 14:00:33 -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 Precedence: bulk List-ID: X-Mailing-List: linux-raid@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 &&