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 55883A00C4; Wed, 12 Oct 2022 14:36:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3CA8A43053; Wed, 12 Oct 2022 14:36:45 +0200 (CEST) Received: from smail.rz.tu-ilmenau.de (smail.rz.tu-ilmenau.de [141.24.186.67]) by mails.dpdk.org (Postfix) with ESMTP id 657204303E for ; Wed, 12 Oct 2022 14:36:44 +0200 (CEST) Received: from localhost.localdomain (dialin-ip-23-165.ilmenau.net [80.88.23.165]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id F0A55580095; Wed, 12 Oct 2022 14:36:43 +0200 (CEST) From: Markus Theil To: David Hunt Cc: dev@dpdk.org, Markus Theil , Reshma Pattan Subject: [PATCH v2] power: fix pstate number parsing Date: Wed, 12 Oct 2022 14:36:37 +0200 Message-Id: <20221012123637.51640-1-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221012113342.7931-1-markus.theil@tu-ilmenau.de> References: <20221012113342.7931-1-markus.theil@tu-ilmenau.de> 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 From: Markus Theil When converting atoi to strtol in a revision of introducing sysfs support for turbo percentage, a necessary check against '\n' returned by sysfs was not introduced. Fixes: de254dac608e ("power: read P-state turbo percentage from sysfs") Reviewed-by: Reshma Pattan Acked-by: Reshma Pattan Signed-off-by: Markus Theil --- lib/power/power_pstate_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 49ddb2eefd..52aa64510e 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -96,7 +96,7 @@ power_read_turbo_pct(uint64_t *outVal) errno = 0; *outVal = (uint64_t) strtol(val, &endptr, 10); - if (*endptr != 0 || errno != 0) { + 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)); ret = -1; -- 2.38.0