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 1423D45B00; Thu, 10 Oct 2024 11:17:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD2E140611; Thu, 10 Oct 2024 11:17:43 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2100.outbound.protection.outlook.com [40.107.223.100]) by mails.dpdk.org (Postfix) with ESMTP id B07EA402D8 for ; Thu, 10 Oct 2024 11:17:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y3SR7awdl0mIv8oqZyrBLWcKhcVaAb6LURo0xIgP7N7SsR7/w5kN3iY/ZgPurUzfBlUs6rFDb5crP5SNiZbHuJXPv7ay0h0ZCM2uuu8h+tSNoNPcp2mwm/EzRchhsA3J3ugMYDZ2GGm0N7rGhuRzrzkky/x5DpaGB5R7m5VkmxLC0TiEVJUlkbTdKlIgOtt/bC3A3tRuxILd6hYjiJ8ESH+sT6ug3FByijIBYD1T7WQqFeSjyqT/o4N4o8J57jV5pKtg+3B4stLwk6qBNM4/6As4L4NteqneBQRUJRBZNk8Wq711PIYkx9rf0TFh/eC+09fWUUPFRqWA3ciXORUk2g== 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=ol+JsUrFzQlgGbzSntt5Qbi6DaknwY40no0T+HcF7gY=; b=kilw3vt4VdUsZsRMpfLZHC7U3B5YCvgoCVCWkt3/XJxCNG8RS2hu0O8VbPUVh7CHto8xB43h2MT9PBhEGpSp520UnoTMarKTldI592pwGEmHHMbDuM6DS6Ez0B4QjSZwzhNGH/LB1fj/BNFp+Xn+SaYR4o8cnuqurJTSnMBoCoQGIG5PzCWqczVSXhEf2c7njNoVPM1MeKBzOnRUQGRfHZC6heAiBy2q9cyEPD6dIBy4ezmrVe4n4ckpdkiycA4qzm9ejjUv4uBK2FcUrRLNh9qf2ku+/xY7R4wtwhc+YGIybxvKbm5gS7n3uzwhEqROFhRIM5xb4V5djpcZUZ+hpQ== 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=ol+JsUrFzQlgGbzSntt5Qbi6DaknwY40no0T+HcF7gY=; b=s1lKhSm70FTrH7FYnlytu96Zr/m4KXfjSaB/R6iHpzCY0N6RAuSwiWkakUIRiekDwtdoT3+LtN88lJugN7Tv7H58Q6k8OwzHthW1e6DV3TnkiQ5xNXl49Q1DEJOfi/qjyNL6iGAk5/rwEFefJhTi7QXR18K85lzDTPCQ/c6Yr1c= 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 MW3PR13MB3980.namprd13.prod.outlook.com (2603:10b6:303:5c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 09:17:38 +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.8026.020; Thu, 10 Oct 2024 09:17:38 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 01/10] net/nfp: use strlcpy for copying string Date: Thu, 10 Oct 2024 17:17:07 +0800 Message-Id: <20241010091716.3631747-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241010091716.3631747-1-chaoyong.he@corigine.com> References: <20241010091716.3631747-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TP0P295CA0060.TWNP295.PROD.OUTLOOK.COM (2603:1096:910:3::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB3980:EE_ X-MS-Office365-Filtering-Correlation-Id: 00a41ae6-fee9-46d3-cfea-08dce90c6269 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zapatdDqNcqI45FSHEAAP4bxBX6AZ0RQo/S78KaT62uVST68bGlet7BLYyN+?= =?us-ascii?Q?DE3Tmi/KCfy8a8tRTZ+UfKI7PEnneUAX42KhltRw+w5Y3fq/KCm19VYYSHwP?= =?us-ascii?Q?X0D/Q0j/BAUwhYX8DqTEai2S2z8udiVvTmwDEg/EuIA72ySyHU6LZa2RjKAU?= =?us-ascii?Q?/psRM+pkSKbB6zGUf40sxSeMRyTcHcDVJ+ugmT4X37iaS2ck8hQkP2bgGQvf?= =?us-ascii?Q?FgFQWmQT5p1aKuHwLVrk9NwpEr+wnCudvBnja1R3ke+FS1+0pXSat8OQmBX8?= =?us-ascii?Q?HfmEyTsuRdkw4YSAaESGiVb9fADZp8v6ZwmSJRnit9rNmx47SoUPEvM1G54b?= =?us-ascii?Q?vjr1rp7ehf/2Dm1W5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tvhOTyvmihQYWVCU1LucSoM8p?= =?us-ascii?Q?PpaXS0+tK1650qSkoGXprmsawiqt2QRMn0/09DbBcFwbMM6FOWTJgwijWcwR?= =?us-ascii?Q?tR+AHWWmYAeYs+Z0x556bDRHFL7wuQoLLjMJz1BVvIQ5Zg=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)(366016)(376014)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?87trY+TjFyEg41AN2GrYPm0pvRjAmogdrH+QvGInUj/xnf3+gZzOqgIG+V+g?= =?us-ascii?Q?fn1vQssaEsSKAkN0SYJcctgpIOWpbr6hoEGdyprzqFV95zxA1UspggmH0XYc?= =?us-ascii?Q?tpNf1KNJ+RMhsitM62SKWa3jsnAikqID8XupwfLd1UY7Oj+eO3cdy8J1kg5X?= =?us-ascii?Q?apzpGOWG2/xoWLgAzuRSwNFWlXRBPifAEKeC2fX6ctqk0EQpGHN4xzHvzRVr?= =?us-ascii?Q?DRxWILkBwCHBEO7oyduEdBgmCpH3IJuo+dpVU4V42RtqDHmZWjyts3vmWagI?= =?us-ascii?Q?MMStpHEBttyHxu8rbPJN2LbEI3vuT1MscrFTc9RceiUleCvZmumpVgwMhH4w?= =?us-ascii?Q?zGjCAVMeaGDb5oyP1vMplei4/T3CagZZGBZBlG/IVRJ7LxHXQuJs40oQ+tQi?= =?us-ascii?Q?Wk/hLlcJQ/kvMMYB+DshuzKiJTb0Ge0dVPNKQGW9jc2R64qE3PEi60IzpUZ1?= =?us-ascii?Q?0SZgpR/YrlU0ENRyUa0ocTQ+ng9oAxgP7XWXfwaC+FkCkSYAPC3bFm6vaHKt?= =?us-ascii?Q?rBa/OPzR3aUX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Q?XYpazkCeAm03/T04L0vN88ZSM92bVGz4g/o9/2umFlLyX9hs9vEgaWWiU+NX?= =?us-ascii?Q?HJe89vxKKXXQzK+53QOuNVFaIoURSd9eAu61TE7NHvm/WEttaIA3j7t/aFGp?= =?us-ascii?Q?5yjH+YnZCYG8vrPAkKqUJsejyK/Gaa3j8GPdF7fsmyTobQSYLATUnq5TQpR/?= =?us-ascii?Q?XQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00a41ae6-fee9-46d3-cfea-08dce90c6269 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:17:38.1928 (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: B1xFNUJ/zbnc2YwZyLnui6jqLPf4C/Eg6IrTXVoKxbxMOowBihmGn3wPHo/0f2CzSaf96y/Mlxx840pQsVI2tcooriA99kRCO7+0UEDrTn4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3980 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 --- 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