Anything coming from sysfs has a newline at the end. Cut it off before
comparing the strings.
Fixes:
20ab67608a39 ("power: add environment capability probing")
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
Tested-by: Lihong Ma <lihongx.ma@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
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;
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;