Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp906718rwb; Thu, 18 Aug 2022 14:37:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR6MTu53eJPnVV3s7NfUQhip8YbdTl6JOQVXksR6yitOQE+F6xBHCR5dxYJY41X48wr5F8Wh X-Received: by 2002:aa7:d0d1:0:b0:445:e46f:3703 with SMTP id u17-20020aa7d0d1000000b00445e46f3703mr3752044edo.55.1660858650871; Thu, 18 Aug 2022 14:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660858650; cv=none; d=google.com; s=arc-20160816; b=MIeJ+2iMnd+av9IrDmIM2Fa8cRVFtMdDJMEDcgAASGfAg/sSV7GjhX3s3yByIeJhts glkX8eCDeec9d13L4jn7+grFfrZQc6wvhmvkGypFUgOYZk0hyi9uNa37AZMqBsOEmlWx 6niqlzSwY5zhT1hdoTflcd3WqDY1rVL9hT9cs8hAM0A/o7BLldzRHoanct1MlHH6txZv HIiZSHZZyYH+7zU+9I8MnZRcir3UBJB8xZV0vcFxUcEtXliUav/9aIzRBKtqdEjiNUYv 8mAYFhlB9tzUzDCzOS4R+Yn64TSKcZx6+bDpcpTPBvPVCpfRtLyUO5Qknfqq2cN6Y0Yg hcxg== 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=PvqfOeaTMBuKnWe61nWAhnBhC22y8YU1pArAmvSXvIE=; b=ipPk54uCOgKhcgqqoTkZIJmtum7L0QSqDGTkhrGDfpv3rEtX4VWhaHLth1dLpkc2M0 8jEI7C9/qzUa9lITDoeGi/Ix1si0QI527ADuhsc/6pnpPpwnwqxOLc9SRSy3MPNpyjrx aI43uIoC8UGs3ZtAXosszIBGLR7YWpRLXMR9rUXD1YcvKPB6wotGhaO8b+GIZkusEpB6 BIAwMoBxltaw+945M5DkWjvwGHTtwJb1VdMbiP74AL7Ir2Mj+TU+QeVRLBHCvwGscSUf QCoaWXBH5zHehbE+ZSllGmlU26eZPwOl4Ji2r6kB+0BdzpVTukcoN05y66CUCRBmO8qD qSaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=UP30jKd4; 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 n8-20020a1709065e0800b00730947701dbsi1474432eju.485.2022.08.18.14.37.04; Thu, 18 Aug 2022 14:37:30 -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=UP30jKd4; 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 S1346991AbiHRVN2 (ORCPT + 99 others); Thu, 18 Aug 2022 17:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346826AbiHRVKf (ORCPT ); Thu, 18 Aug 2022 17:10:35 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E4FD91C6 for ; Thu, 18 Aug 2022 14:05:29 -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=sYiHmEK6bZEF0P5UzHlJveW5qS8 Z2Ogah+TiQbRB2XY=; b=UP30jKd4X1RGxQ3k97aj0E2PQ5ADpEwm96KVlYeczOg 1fv+Ch9A8JLniISbfuwfp/yIsqFcXHJ+xYwC4MjtdbXh34F+nAABDhwEFX4KL/ea /xOagHWreVnnZa/ROJPE9zLu2QoIsmc7FOEJ20ung7SbnGea31AmQKpkpwciKUwM = Received: (qmail 3963050 invoked from network); 18 Aug 2022 23:02:16 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:02:16 +0200 X-UD-Smtp-Session: l3s3148p1@onXWS4rmbucucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Neil Horman , netdev@vger.kernel.org Subject: [PATCH] net: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:02:15 +0200 Message-Id: <20220818210215.8395-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 --- net/core/dev.c | 4 ++-- net/core/drop_monitor.c | 2 +- net/core/netpoll.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 716df64fcfa5..09058fe676ea 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1100,7 +1100,7 @@ static int dev_alloc_name_ns(struct net *net, BUG_ON(!net); ret = __dev_alloc_name(net, name, buf); if (ret >= 0) - strlcpy(dev->name, buf, IFNAMSIZ); + strscpy(dev->name, buf, IFNAMSIZ); return ret; } @@ -1137,7 +1137,7 @@ static int dev_get_valid_name(struct net *net, struct net_device *dev, else if (netdev_name_in_use(net, name)) return -EEXIST; else if (dev->name != name) - strlcpy(dev->name, name, IFNAMSIZ); + strscpy(dev->name, name, IFNAMSIZ); return 0; } diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c index 75501e1bdd25..876664fc605e 100644 --- a/net/core/drop_monitor.c +++ b/net/core/drop_monitor.c @@ -464,7 +464,7 @@ net_dm_hw_trap_summary_probe(void *ignore, const struct devlink *devlink, goto out; hw_entry = &hw_entries->entries[hw_entries->num_entries]; - strlcpy(hw_entry->trap_name, metadata->trap_name, + strscpy(hw_entry->trap_name, metadata->trap_name, NET_DM_MAX_HW_TRAP_NAME_LEN - 1); hw_entry->count = 1; hw_entries->num_entries++; diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 5d27067b72d5..9be762e1d042 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -556,7 +556,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) if ((delim = strchr(cur, ',')) == NULL) goto parse_failed; *delim = 0; - strlcpy(np->dev_name, cur, sizeof(np->dev_name)); + strscpy(np->dev_name, cur, sizeof(np->dev_name)); cur = delim; } cur++; @@ -610,7 +610,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev) int err; np->dev = ndev; - strlcpy(np->dev_name, ndev->name, IFNAMSIZ); + strscpy(np->dev_name, ndev->name, IFNAMSIZ); if (ndev->priv_flags & IFF_DISABLE_NETPOLL) { np_err(np, "%s doesn't support polling, aborting\n", -- 2.35.1