test/telemetry: fix typo at beginning of line
[dpdk.git] / lib / librte_power / power_common.c
index 59023d9..67e3318 100644 (file)
@@ -17,6 +17,7 @@ cpufreq_check_scaling_driver(const char *driver_name)
        unsigned int lcore_id = 0; /* always check core 0 */
        char fullpath[PATH_MAX];
        char readbuf[PATH_MAX];
+       size_t end_idx;
        char *s;
        FILE *f;
 
@@ -39,6 +40,13 @@ cpufreq_check_scaling_driver(const char *driver_name)
        if (s == NULL)
                return 0;
 
+       /* when read from sysfs, driver name has an extra newline at the end */
+       end_idx = strnlen(readbuf, sizeof(readbuf));
+       if (end_idx > 0 && readbuf[end_idx - 1] == '\n') {
+               end_idx--;
+               readbuf[end_idx] = '\0';
+       }
+
        /* does the driver name match? */
        if (strncmp(readbuf, driver_name, sizeof(readbuf)) != 0)
                return 0;