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 C9BC142C04; Thu, 1 Jun 2023 17:04:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BDF742DBF; Thu, 1 Jun 2023 17:01:35 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id B72D042DAB for ; Thu, 1 Jun 2023 17:01:32 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1b0218c979cso5065735ad.3 for ; Thu, 01 Jun 2023 08:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685631691; x=1688223691; 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=CTvwsqDlltB9bgXoPUp/FsEl/z0wa37pIpMd9rwJ9rk=; b=wXu0wNwT5SlTXf4IP5yuooHR/9mCHMI6HZ7wedYvESlTKQXebo6Vr6oe1/5GmVAIBb G9FrUbXvIdPVy1yaPCwy23vTaiQ40Js2iRDOis3sN7ls+dKke6ejX6V4vMewotsHCcuE BK4CYXtfRhq05bNCqNYjphCkGkEc70pTwKsn8NVQp05cCqajU6YhhR/Cv6V8uDTEPw9E xDXiH7u1x3WBJb9QsEXnw9uUXWVGHAHA+czU2kuQvLB8nxRWiOmpOrFeZKI2fKtwBfjr vG2dhEJQI15kjFgLX28/3ucidSThvin5KI7AXukrXWwnrpr9RHTghd2m+FjsQbsFtIjD +dMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631691; x=1688223691; 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=CTvwsqDlltB9bgXoPUp/FsEl/z0wa37pIpMd9rwJ9rk=; b=Nn72GJOHbwFKCXw94YzxTMNtk0BTywT8Za7yoVBOsci+kmBv379wr4iAnXrsgV07XT f8Fw7+P4BQFcz2DkulzvPZkiL8QIqVyG5YUHJFuGDyMA8FYwS9B93O3j2aGcz+eZwS5H Hs9sON08yt5KzueHyceJBSB8eyY571UL11gys2CyOydjfURm04KPwruLljJMWJIEtAf0 inPs8F2BjwMTPxNvfJAJj4ZbURj+SSu4Yrjias9N+f8cHIU+ioKjKkrs+fHKmxJkUk9h hRJGVTmOIHe4ize8Z7dz6RjHmL8hWOJH7d18/b3UlWrc9bVJCmMNEJLqzf6WTfdVpq6h ypUg== X-Gm-Message-State: AC+VfDxDLsa+Tl1SLyzRuet9A7dD2J1ADnQ5reNqIh3+bY3Hqwq2UggH ehxhfntddLVfVZ2znLMex+YCEq/daReZBQRL02+WRg== X-Google-Smtp-Source: ACHHUZ4K5q+LxL0u6snECZ9ZD/leM8UXB6gik353uU27L8A1tlTVNV2jq2fJuSdfeIFtfEUYQ14QsQ== X-Received: by 2002:a17:902:aa09:b0:1ad:edbd:8541 with SMTP id be9-20020a170902aa0900b001adedbd8541mr6124504plb.13.1685631691536; Thu, 01 Jun 2023 08:01:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou Subject: [PATCH 17/25] net/hinic: replace snptintf with strlcpy Date: Thu, 1 Jun 2023 08:00:58 -0700 Message-Id: <20230601150106.18375-18-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/hinic/base/hinic_compat.h | 1 + drivers/net/hinic/base/hinic_pmd_niccfg.c | 4 +--- drivers/net/hinic/hinic_pmd_ethdev.c | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index aea332046ede..e8d0badb792a 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -19,6 +19,7 @@ #include #include #include +#include typedef uint8_t u8; typedef int8_t s8; diff --git a/drivers/net/hinic/base/hinic_pmd_niccfg.c b/drivers/net/hinic/base/hinic_pmd_niccfg.c index 8c08d63286df..eb127a308a0b 100644 --- a/drivers/net/hinic/base/hinic_pmd_niccfg.c +++ b/drivers/net/hinic/base/hinic_pmd_niccfg.c @@ -1337,7 +1337,7 @@ int hinic_get_mgmt_version(void *hwdev, char *fw) return -EIO; } - snprintf(fw, HINIC_MGMT_VERSION_MAX_LEN, "%s", fw_ver.ver); + strlcpy(fw, (const char *)fw_ver.ver, HINIC_MGMT_VERSION_MAX_LEN); return 0; } @@ -2115,5 +2115,3 @@ int hinic_set_fdir_tcam_rule_filter(void *hwdev, bool enable) return err; } - - diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index 7aa5e7d8e929..bb4d5a3f0f85 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -786,7 +786,7 @@ static int hinic_fw_version_get(struct rte_eth_dev *dev, char *fw_version, if (fw_size < strlen(fw_ver) + 1) return (strlen(fw_ver) + 1); - snprintf(fw_version, fw_size, "%s", fw_ver); + strlcpy(fw_version, fw_ver, fw_size); return 0; } @@ -2302,9 +2302,9 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev, /* get vport stats */ for (i = 0; i < HINIC_VPORT_XSTATS_NUM; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", hinic_vport_stats_strings[i].name); + strlcpy(xstats_names[count].name, + hinic_vport_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } @@ -2313,9 +2313,9 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev, /* get phy port stats */ for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", hinic_phyport_stats_strings[i].name); + strlcpy(xstats_names[count].name, + hinic_phyport_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } -- 2.39.2