Skip to content

Commit

Permalink
tools/power turbostat: Fix names matching
Browse files Browse the repository at this point in the history
Fix the 'find_msrp_by_name()' function which returns incorrect matches for
cases like this:

s1 = "C1-";
find_msrp_by_name(head, s1);

Inside 'find_msrp_by_name()':
...
s2 = "C1"
if !(strcnmp(s1, s2, len(s2)))
	// Incorrect match!
	return mp;

Full strings should be match istead. Switch to 'strcmp()' to fix the problem.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Artem Bityutskiy authored and Len Brown committed Feb 9, 2025
1 parent b312d88 commit 5132681
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -9612,7 +9612,7 @@ struct msr_counter *find_msrp_by_name(struct msr_counter *head, char *name)
for (mp = head; mp; mp = mp->next) {
if (debug)
fprintf(stderr, "%s: %s %s\n", __func__, name, mp->name);
if (!strncmp(name, mp->name, strlen(mp->name)))
if (!strcmp(name, mp->name))
return mp;
}
return NULL;
Expand Down

0 comments on commit 5132681

Please sign in to comment.