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 AF24E43325; Tue, 14 Nov 2023 09:26:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D084E406FF; Tue, 14 Nov 2023 09:25:51 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id A67A8402E8 for ; Tue, 14 Nov 2023 09:25:42 +0100 (CET) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4STzmv1L3Lz1P8J5; Tue, 14 Nov 2023 16:22:23 +0800 (CST) Received: from localhost.huawei.com (10.50.165.33) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 14 Nov 2023 16:25:41 +0800 From: Dengdui Huang To: CC: , , , , Subject: [PATCH 07/43] power: use rte strerror Date: Tue, 14 Nov 2023 16:25:03 +0800 Message-ID: <20231114082539.1858594-8-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231114082539.1858594-1-huangdengdui@huawei.com> References: <20231114082539.1858594-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected 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 The function strerror() is insecure in a multi-thread environment. This patch uses rte_strerror() to replace it. Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng --- lib/power/guest_channel.c | 7 ++++--- lib/power/power_kvm_vm.c | 3 ++- lib/power/power_pstate_cpufreq.c | 7 ++++--- lib/power/rte_power_pmd_mgmt.c | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c index 7b2ae0b650..1484b384df 100644 --- a/lib/power/guest_channel.c +++ b/lib/power/guest_channel.c @@ -14,6 +14,7 @@ #include #include +#include #include "guest_channel.h" @@ -75,7 +76,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) fd = open(fd_path, O_RDWR); if (fd < 0) { RTE_LOG(ERR, GUEST_CHANNEL, "Unable to connect to '%s' with error " - "%s\n", fd_path, strerror(errno)); + "%s\n", fd_path, rte_strerror(errno)); return -1; } @@ -104,7 +105,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) if (ret != 0) { RTE_LOG(ERR, GUEST_CHANNEL, "Error on channel '%s' communications test: %s\n", - fd_path, ret > 0 ? strerror(ret) : + fd_path, ret > 0 ? rte_strerror(ret) : "channel not connected"); goto error; } @@ -184,7 +185,7 @@ int power_guest_channel_read_msg(void *pkt, return -1; } else if (ret < 0) { RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n", - strerror(errno)); + rte_strerror(errno)); return -1; } diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c index 6a8109d449..bb9c9b95fe 100644 --- a/lib/power/power_kvm_vm.c +++ b/lib/power/power_kvm_vm.c @@ -5,6 +5,7 @@ #include #include +#include #include "rte_power_guest_channel.h" #include "guest_channel.h" @@ -82,7 +83,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) if (ret == 0) return 1; RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", - ret > 0 ? strerror(ret) : "channel not connected"); + ret > 0 ? rte_strerror(ret) : "channel not connected"); return -1; } diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 5ca5f60bcd..eeb0f3831b 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -13,6 +13,7 @@ #include #include +#include #include "rte_power_pmd_mgmt.h" #include "power_pstate_cpufreq.h" @@ -83,7 +84,7 @@ power_read_turbo_pct(uint64_t *outVal) if (fd < 0) { RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT, - strerror(errno)); + rte_strerror(errno)); return fd; } @@ -91,7 +92,7 @@ power_read_turbo_pct(uint64_t *outVal) if (ret < 0) { RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT, - strerror(errno)); + rte_strerror(errno)); goto out; } @@ -99,7 +100,7 @@ power_read_turbo_pct(uint64_t *outVal) *outVal = (uint64_t) strtol(val, &endptr, 10); if (errno != 0 || (*endptr != 0 && *endptr != '\n')) { RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n", - POWER_SYSFILE_TURBO_PCT, strerror(errno)); + POWER_SYSFILE_TURBO_PCT, rte_strerror(errno)); ret = -1; goto out; } diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 38f8384085..a61a5c8f98 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -574,7 +574,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, ret = queue_list_add(lcore_cfg, &qdata); if (ret < 0) { RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n", - strerror(-ret)); + rte_strerror(-ret)); goto end; } /* new queue is always added last */ -- 2.33.0