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 A000842C04; Thu, 1 Jun 2023 17:04:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE88A42F9E; Thu, 1 Jun 2023 17:01:38 +0200 (CEST) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 7E84042DC8 for ; Thu, 1 Jun 2023 17:01:36 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1b02497f4cfso4712265ad.3 for ; Thu, 01 Jun 2023 08:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685631695; x=1688223695; 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=8dqrjxEsQL5vuVPAXCkZC0SCxHc+z1y3yRa7Zuhkn5c=; b=zDaHNyhpHM1zUREyQ4s/t/09fpCK3s+8ASDpujCR/Jbi9vNva0vYoiqT79KXiPiKC5 A8SBreSQ7u2R0BxzpVjJgCKNCzeZJ/IuBWsKXNWlv/noq/lJ6YFYddWVuJKQhq+6/f/f 9dRPBo6Ejy2eRlVTCx+6Mz/jq4khD0gucLKtgJGx1tSU5gHrgdOwqW0+DbsRU+OsE/H9 PfFkzVpy3XMrWbUmRCQ6VTxm8oTvqysIqnuZtC3n+n3rDZdUgQjcUt5SnS1hmZqtRTwS lzJsfb87uphV+3qe2ZhGuIX/ac1OIzXb2LAwj+R6hx+bnEhisC7Ph4fZvcrnVflCj+G8 naMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631695; x=1688223695; 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=8dqrjxEsQL5vuVPAXCkZC0SCxHc+z1y3yRa7Zuhkn5c=; b=DHuEUbyiuiekaUlrFwVdRv80DyRxLdPtxn5OqBKcSnXskzqiDLXqC9L3n8rzR93ONV hZXpm2qcC6G24LSuaqDSPt0FS7ZSYQGyVzar+CMs1PkXbipnpoUw/NDw7JZ4Yyef/58W PA/po7tjOZzMFIKx4LT1ooYLdhL/ER33RGof9HbstT2xwOQNqdRJZxicn3Vg67eFhNrY Tc+3407WVo3JvdJiSCYp2ir0bbw48FPA0QXAdi1QakM93IlsrFuWmz/dVtt+o1Uan7zZ +0bnuHv2nFO66kLz9zC25uf8c/VpR94uOjzotaz/SU2hbdooUpdNjXv+v2KlF5uWI2RO AOZA== X-Gm-Message-State: AC+VfDwXLQy5P4nCLrSB7o1s0RMshba38XlPP3AYxJzaA914dYJkfl1Q ax8ypwYXrWpQBVdeJ/EkNDRbE6QaNb7EzdAuYBHX7A== X-Google-Smtp-Source: ACHHUZ5xmZsDnZCNiMtGxbzZWiUDjnFnlUyf+MtM2aIG3gVqAqkAvvoLk6ENL9NF3HDDhVN2OYQffg== X-Received: by 2002:a17:902:9002:b0:1a9:7ffb:5ed0 with SMTP id a2-20020a170902900200b001a97ffb5ed0mr5791644plp.59.1685631695512; Thu, 01 Jun 2023 08:01:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Boyer , Rosen Xu Subject: [PATCH 20/25] net/ionic: replace snprintf with strlcpy Date: Thu, 1 Jun 2023 08:01:01 -0700 Message-Id: <20230601150106.18375-21-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/ionic/ionic_ethdev.c | 15 +++++++-------- drivers/net/ipn3ke/ipn3ke_representor.c | 17 +++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 340fd0cd5923..c6f6342e52f8 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -208,8 +208,7 @@ ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, struct ionic_adapter *adapter = lif->adapter; int ret; - ret = snprintf(fw_version, fw_size, "%s", - adapter->fw_version); + ret = strlcpy(fw_version, adapter->fw_version, fw_size); if (ret < 0) return -EINVAL; @@ -705,9 +704,9 @@ ionic_dev_xstats_get_names(__rte_unused struct rte_eth_dev *eth_dev, if (xstats_names != NULL) { for (i = 0; i < IONIC_NB_HW_STATS; i++) { - snprintf(xstats_names[i].name, - sizeof(xstats_names[i].name), - "%s", rte_ionic_xstats_strings[i].name); + strlcpy(xstats_names[i].name, + rte_ionic_xstats_strings[i].name, + sizeof(xstats_names[i].name)); } } @@ -725,9 +724,9 @@ ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, if (!ids) { if (xstats_names != NULL) { for (i = 0; i < IONIC_NB_HW_STATS; i++) { - snprintf(xstats_names[i].name, - sizeof(xstats_names[i].name), - "%s", rte_ionic_xstats_strings[i].name); + strlcpy(xstats_names[i].name, + rte_ionic_xstats_strings[i].name, + sizeof(xstats_names[i].name)); } } diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c index e50fc73f43c4..feafe9679907 100644 --- a/drivers/net/ipn3ke/ipn3ke_representor.c +++ b/drivers/net/ipn3ke/ipn3ke_representor.c @@ -124,8 +124,7 @@ ipn3ke_rpst_dev_start(struct rte_eth_dev *dev) rawdev = hw->rawdev; memset(attr_name, 0, sizeof(attr_name)); - snprintf(attr_name, IPN3KE_RAWDEV_ATTR_LEN_MAX, "%s", - "LineSideBaseMAC"); + strlcpy(attr_name, "LineSideBaseMAC", IPN3KE_RAWDEV_ATTR_LEN_MAX); rawdev->dev_ops->attr_get(rawdev, attr_name, &base_mac); rte_ether_addr_copy((struct rte_ether_addr *)&base_mac, &rpst->mac_addr); @@ -2330,19 +2329,17 @@ __rte_unused unsigned int limit) /* Get stats from ipn3ke_rpst_stats */ for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", - ipn3ke_rpst_stats_strings[i].name); + strlcpy(xstats_names[count].name, + ipn3ke_rpst_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } /* Get individual stats from ipn3ke_rpst_hw_port */ for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", - ipn3ke_rpst_hw_port_strings[i].name); + strlcpy(xstats_names[count].name, + ipn3ke_rpst_hw_port_strings[i].name, + sizeof(xstats_names[count].name)); count++; } -- 2.39.2