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 1588442C04; Thu, 1 Jun 2023 17:04:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 940C742DCF; Thu, 1 Jun 2023 17:01:36 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 84F6242DAE for ; Thu, 1 Jun 2023 17:01:33 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1b025d26f4fso8144505ad.1 for ; Thu, 01 Jun 2023 08:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685631692; x=1688223692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H+qK5KLsp4zBm++ghShYmDp9X/nFOGl4xmclx72bFbk=; b=VBj8ebd25hV20JjQMA2lXo2p8ia4KxkbPGtRj1cuyCaCrLW0+b371i6xJHBUOv9NuI 0euH2qgaPfCsKIZum3wrah6fRENpYL1mdxdwf6GaW9/N4fB08k3wSEhMPkAS+dHYrerN xCs1f3A1a8upHIM0yD6ESm7dBx5ltFgpc4mGW/yge17OB1kIdjVYL8eNC7ULgD8T9oIc B8SnQOEujfQJLi85mSJiovI4KzFD8H3C+8e5ztnsyIGdzq2/xOzJV/MnHZ2SKR6TrVsZ GGqFpop4rn+xXN2Bwqq5f4hIdTIhAVHPXHKzPFn9dkO1yupt13ZVSwhCh4KUeWExd1gn M1Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631692; x=1688223692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H+qK5KLsp4zBm++ghShYmDp9X/nFOGl4xmclx72bFbk=; b=I1opJudbbsM/IqPnEYMmccQX5mQuPJ1RnpG2kA6UsPOI4uOwgsQzfWWLC3aeo6q82T e5iBLlDIMK/b9BeBr0XZjr5qCiVXBJqD2cnJ914Jh34X5sqD4HDdzlim9ZbkatdPcrQJ cvs12zBUf36xAQjOiZJv+BzT+hPREeMIuQ0AYcFoi4L8uL0LQllFns0M315ZyOn2aGlA jBPmjMqlodTw7oForxvKV5slbg1NQ5+OhKADVVMv9PXcmN925zHve3dCpC9kf/2c3tjX 3+CMO5Ra3N3zYJbx6+5w/4CP+JmDnWIeeCr8Q9NcdoTDFlQ8/1qoDxGqWlIVKJW2r2sj QoxA== X-Gm-Message-State: AC+VfDxRjeOK7ylFTlAnxtytaonoCNnaMSy0EeFmsEpT692jQqQDCSGd GVY4Il8SwXBiu80OyjuHO9u7RkolmbJhHsKeDWmeFw== X-Google-Smtp-Source: ACHHUZ45KWbY5lqwrVyBOjWZjVN3DgdxRlfZ0VQRWLhrq8KkPkRZTXolSMvLmxPktgEDbttwyvmcCw== X-Received: by 2002:a17:902:ea0c:b0:1ac:84dd:6d1f with SMTP id s12-20020a170902ea0c00b001ac84dd6d1fmr10281086plg.1.1685631692468; Thu, 01 Jun 2023 08:01:32 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id ij9-20020a170902ab4900b001ac40488620sm3661955plb.92.2023.06.01.08.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Dongdong Liu , Yisen Zhuang Subject: [PATCH 18/25] net/hns3: replace snprint with strlcpy Date: Thu, 1 Jun 2023 08:00:59 -0700 Message-Id: <20230601150106.18375-19-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601150106.18375-1-stephen@networkplumber.org> References: <20230601150106.18375-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Suggested by devtools/cocci/strlcpy-with-header.cocci Signed-off-by: Stephen Hemminger --- drivers/net/hns3/hns3_fdir.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 8 ++++---- drivers/net/hns3/hns3_stats.c | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c index 48a91fb517de..766416432c57 100644 --- a/drivers/net/hns3/hns3_fdir.c +++ b/drivers/net/hns3/hns3_fdir.c @@ -843,7 +843,7 @@ int hns3_fdir_filter_init(struct hns3_adapter *hns) fdir_hash_params.socket_id = rte_socket_id(); TAILQ_INIT(&fdir_info->fdir_list); - snprintf(fdir_hash_name, RTE_HASH_NAMESIZE, "%s", hns->hw.data->name); + strlcpy(fdir_hash_name, hns->hw.data->name, RTE_HASH_NAMESIZE); fdir_info->hash_handle = rte_hash_create(&fdir_hash_params); if (fdir_info->hash_handle == NULL) { PMD_INIT_LOG(ERR, "Create FDIR hash handle fail!"); diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 4065c519c329..78921edcc9ab 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2795,8 +2795,8 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, for (i = 0; i < RTE_DIM(burst_infos); i++) { if (pkt_burst == burst_infos[i].pkt_burst) { - snprintf(mode->info, sizeof(mode->info), "%s", - burst_infos[i].info); + strlcpy(mode->info, burst_infos[i].info, + sizeof(mode->info)); ret = 0; break; } @@ -4290,8 +4290,8 @@ hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, for (i = 0; i < RTE_DIM(burst_infos); i++) { if (pkt_burst == burst_infos[i].pkt_burst) { - snprintf(mode->info, sizeof(mode->info), "%s", - burst_infos[i].info); + strlcpy(mode->info, burst_infos[i].info, + sizeof(mode->info)); ret = 0; break; } diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index bad65fcbed8b..2fd460813919 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -1176,9 +1176,9 @@ hns3_imissed_stats_name_get(struct rte_eth_dev *dev, imissed_stats_num = hns3_get_imissed_stats_num(hns); for (i = 0; i < imissed_stats_num; i++) { - snprintf(xstats_names[cnt].name, - sizeof(xstats_names[cnt].name), - "%s", hns3_imissed_stats_strings[i].name); + strlcpy(xstats_names[cnt].name, + hns3_imissed_stats_strings[i].name, + sizeof(xstats_names[cnt].name)); cnt++; } @@ -1228,9 +1228,9 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, if (!hns->is_vf) { /* Get MAC name from hw->hw_xstats.mac_stats struct */ for (i = 0; i < HNS3_NUM_MAC_STATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", hns3_mac_strings[i].name); + strlcpy(xstats_names[count].name, + hns3_mac_strings[i].name, + sizeof(xstats_names[count].name)); count++; } } @@ -1238,9 +1238,9 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, hns3_imissed_stats_name_get(dev, xstats_names, &count); for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", hns3_reset_stats_strings[i].name); + strlcpy(xstats_names[count].name, + hns3_reset_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } @@ -1418,8 +1418,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, rte_free(names_copy); return -EINVAL; } - snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), - "%s", names_copy[ids[i]].name); + strlcpy(xstats_names[i].name, names_copy[ids[i]].name, + sizeof(xstats_names[i].name)); } rte_free(names_copy); -- 2.39.2