From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8480B45B17; Sat, 12 Oct 2024 04:41:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 98B32402EE; Sat, 12 Oct 2024 04:41:38 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2102.outbound.protection.outlook.com [40.107.101.102]) by mails.dpdk.org (Postfix) with ESMTP id E275440272 for ; Sat, 12 Oct 2024 04:41:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OMUA7fG3v8Lh1hXXbZBAxMSFUarv8wNAgweu7qhPFtSUBJlBAsdjMp/UgnRrmv5fw6rTUeUTElgMTE4aJoAQ4WLToLXpO+uGLe2kk6VxqUvUQEaa/Tg4DQntZH73j4tlVs29k8mO4S5bQQ9w8bx9xVsCqKADMStbrky9idryQUz2+SM7ROX9aJ2fv3Eu1RjiJRM8abLVE0t+RTZkey0piMQ3eiAUt7Dbj5Brc8MCte6vOc/tXlGOLrRTC4ridLtFfJydIkN5Pm279ll/ouR4b02QRKyxlQwR7HAjKfUYC71EU/PLE8DisuSlE+ZM9pSV5Ko4wFHnVEPVWUybne/5Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nyWvxOK8OkYkSUNDAoWZATYTNfCTOhTyqsFEuQpkKYM=; b=M38dRHuKpJzuT4RkU1UCtEHyALSKl+XhLNk1wP6KiJK9gjzMdzhd4cCexIYOg0ZhiJn3iI+V3DnGNDpvNveW/WcKzEeLp7aT6XYq70Od7GcZBhND7B03GCqUJEyzfZJHb6yOcVojEj6hGXBFIolYBIIIXFV1W5ichMGFpSerdhQUVtUfSCYWsxcapxfi0wkc5UGLT/ygAodU14bf19jrNCqaQkaLbPd5acZaZX/aOUbYGCf+K72X5qtYBdTIrmYPL+jbdmLf4OUv2EcadYj3PVKJGMwiEt4H3y9QPbNOjV8CxTZAV3vLJ885R9WK1UhpXqP78yU4oh58AQQiP12P4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nyWvxOK8OkYkSUNDAoWZATYTNfCTOhTyqsFEuQpkKYM=; b=Y50esSbBfYoflWPrhpl490yyIxPXA5Cqx6TqWTCsWz1FEOSIrwtO5TqhYeKjEka59YyAL+oK+ZKyB4AiXj9xkITS1VOCOyi4/Bu8h4YBOgg5hwhBzAmNUEr137kiHFPFXBB7hgAfpaDINCe0oTNYwAJnP3Dp7fFwO3SfhSp06fs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by CO1PR13MB4902.namprd13.prod.outlook.com (2603:10b6:303:f0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.21; Sat, 12 Oct 2024 02:41:33 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%5]) with mapi id 15.20.8048.017; Sat, 12 Oct 2024 02:41:33 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang , Stephen Hemminger Subject: [PATCH v2 01/10] net/nfp: use strlcpy for copying string Date: Sat, 12 Oct 2024 10:40:58 +0800 Message-Id: <20241012024107.3795935-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241012024107.3795935-1-chaoyong.he@corigine.com> References: <20241010091716.3631747-1-chaoyong.he@corigine.com> <20241012024107.3795935-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::21) To PH0PR13MB5568.namprd13.prod.outlook.com (2603:10b6:510:12b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO1PR13MB4902:EE_ X-MS-Office365-Filtering-Correlation-Id: b3e53612-18f9-4e8b-960a-08dcea676278 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iO9c13bwPrrawgWp6bk8IXnlbaww14T90R1Ei6jQlZIbOTl5ik+u0Ue/cA4r?= =?us-ascii?Q?mzOFgaGzS34lFybgkeezBSdKN9Lc3nZrDmQkJHai4SFq20zOnRwNrh37pgsS?= =?us-ascii?Q?khANEPV2OV2O04L9YCmTzLViDZ4KviaAdjnmSuXtxrGjQMav27jhWDM+Zs9W?= =?us-ascii?Q?m+zcizHnJ0WjR9XIZzJVNdv15upcZu/uUEsvHjLjDymft0ml4SShi/iFyL+M?= =?us-ascii?Q?IZD8u9g9fRW6L5bhxgFS36YG6tLSiw4+PT4Ut5ljb2X5iiGkMCClM50Qn3GR?= =?us-ascii?Q?YrjZmXDORWnBfohJaenRVV92j8bOOLDV8uzrsFS8yh+C+6f0PIhVO58vdCC9?= =?us-ascii?Q?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TKO27yvHuqk?= =?us-ascii?Q?Tg2G3kXbQ2/rEhJT7Pwld7KebHdjs8p6GJ8Syw37KGt4Ql8nebWvC4IEAjF8?= =?us-ascii?Q?LhlfolGwzYE8gdTd1NR7UyVK5vAd1vDH4/c/jEb2xdGwEg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?QTwrlwCsi46RQIfkW+jkUeL1h3tQIkT/bYqvYTpz9CQhS3H8JNqEYPxXPG36?= =?us-ascii?Q?D445GuQmJBKcyMdc3IES5uKbbJwSiZcW1vhDagz4mHSYgCtmmUjUEmv24UIL?= =?us-ascii?Q?fWG8MvrxzmQsKEFwnvHKNohwbGJtOideINB2vkPUoxW+DUqkqio1wA0G950V?= =?us-ascii?Q?p0qyTZ1PAOuw/JSz7fpaZDMoHOhBjHPJdCDF/It2UYRYpXFwv3tJ5kstYUUm?= =?us-ascii?Q?vt3+qeguWkG0ZhUdIo9mmx+Pn2XsM/227X9ZSTISQU6nV27413+xhyRU5uWw?= =?us-ascii?Q?QiZjYtvqgxnuLRSOqgXBdhjFBpb6YBjXPjJCsW5VbL2gWgbwAKXtCdjesJJQ?= =?us-ascii?Q?aOXQGGxRL43rH0Pn402/FW7CjVaxtVQmi9Im0DHeo+Zw53Cw/NTi3/g+w0rB?= =?us-ascii?Q?jt+0aTdcz4De2MqAVun4AVUcIrFNT6YlRamRVnexlfof++RGNLVJiEiHyneM?= =?us-ascii?Q?1DjXOu2YcxBWaMw7yRR6OmImqEVPUEtMgpusPzhsNbC9hDuUJsNprtAvd3bN?= =?us-ascii?Q?tCZv9Xvrp9PHZ8fsYVUx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ascii?Q?UlcUjXvHGfjFeMdALdF/idfN4ek0crq45I9Len/2i4Z8zvKth4Cl59RdWIc/?= =?us-ascii?Q?C53MUroJo5EXpn2NpY8/EvSNS648fI76L+vYTERJ4V2TYZBdeQ9RM5vScP8/?= =?us-ascii?Q?pIKp3JUlauzBsVHUqydR7VwxafyTEYd4KrhYNaNYZb++6vQlX6a2h/gY3SRz?= =?us-ascii?Q?Zw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3e53612-18f9-4e8b-960a-08dcea676278 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB5568.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2024 02:41:33.7452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Lj9mdTKhWEhIUGPnRUfFkC1EuwE8lH2WQipzG1jST4iQdzfHZV6SookCmljxaTYXdqQBEtdgBarlzPF+6RlY3FtaCaGoaZH+2x1VA2zSQFo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR13MB4902 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace 'snprintf()' with 'strlcpy()' where applicable. Using 'strlcpy()' is safe practice when copying strings, as it will include a null terminator. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang Acked-by: Stephen Hemminger --- drivers/net/nfp/flower/nfp_flower_representor.c | 4 ++-- drivers/net/nfp/nfp_net_common.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 5db7d50618..d1558b905c 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -576,7 +576,7 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev, repr->repr_type = init_repr_data->repr_type; repr->app_fw_flower = init_repr_data->app_fw_flower; - snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name); + strlcpy(repr->name, init_repr_data->name, sizeof(repr->name)); eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops; eth_dev->rx_pkt_burst = nfp_net_recv_pkts; @@ -652,7 +652,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, repr->repr_type = init_repr_data->repr_type; repr->app_fw_flower = init_repr_data->app_fw_flower; - snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name); + strlcpy(repr->name, init_repr_data->name, sizeof(repr->name)); eth_dev->dev_ops = &nfp_flower_repr_dev_ops; eth_dev->rx_pkt_burst = nfp_flower_repr_rx_burst; diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 4a2c536704..c9a95ed632 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -2306,7 +2306,7 @@ nfp_net_get_mip_name(struct nfp_net_hw_priv *hw_priv, if (mip == NULL) return; - snprintf(mip_name, FW_VER_LEN, "%s", nfp_mip_name(mip)); + strlcpy(mip_name, nfp_mip_name(mip), FW_VER_LEN); nfp_mip_close(mip); } @@ -2317,13 +2317,13 @@ nfp_net_get_app_name(struct nfp_net_hw_priv *hw_priv, { switch (hw_priv->pf_dev->app_fw_id) { case NFP_APP_FW_CORE_NIC: - snprintf(app_name, FW_VER_LEN, "%s", "nic"); + strlcpy(app_name, "nic", FW_VER_LEN); break; case NFP_APP_FW_FLOWER_NIC: - snprintf(app_name, FW_VER_LEN, "%s", "flower"); + strlcpy(app_name, "flower", FW_VER_LEN); break; default: - snprintf(app_name, FW_VER_LEN, "%s", "unknown"); + strlcpy(app_name, "unknown", FW_VER_LEN); break; } } -- 2.39.1