Currently the Power Libray stores the governor name with an embedded newline read from the scaling_governor sysfs file. This patch strips it out.
Fixes: 445c6528b55f ("power: common interface for guest and host") Cc: sta...@dpdk.org Signed-off-by: David Hunt <david.h...@intel.com> --- lib/librte_power/power_acpi_cpufreq.c | 4 ++++ lib/librte_power/power_pstate_cpufreq.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index 45412f0b9..c2febdf06 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -147,6 +147,10 @@ power_set_governor_userspace(struct rte_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 9c1a1625f..90a7eff35 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -292,6 +292,10 @@ power_set_governor_performance(struct pstate_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is performance */ if (strncmp(buf, POWER_GOVERNOR_PERF, -- 2.17.1