mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
x86_energy_perf_policy: Fix optarg keyword matching
Replace strncmp() with strcmp() for exact string matching in
parse_optarg_string(). Exact keyword matching is safer and clearer.
This prevents accidental matches with longer strings
like "performance-foo".
Fixes: 4beec1d751 ("tools/power x86_energy_perf_policy: support HWP.EPP")
Assisted-by: GitHub-Copilot:Claude-Sonnet-4.6
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
db2cffbc80
commit
0177067d19
|
|
@ -337,22 +337,22 @@ long parse_optarg_string(char *s)
|
|||
long i;
|
||||
char *endptr;
|
||||
|
||||
if (!strncmp(s, "default", 7))
|
||||
if (strcmp(s, "default") == 0)
|
||||
return OPTARG_NORMAL;
|
||||
|
||||
if (!strncmp(s, "normal", 6))
|
||||
if (strcmp(s, "normal") == 0)
|
||||
return OPTARG_NORMAL;
|
||||
|
||||
if (!strncmp(s, "power", 9))
|
||||
if (strcmp(s, "power") == 0)
|
||||
return OPTARG_POWER;
|
||||
|
||||
if (!strncmp(s, "balance-power", 17))
|
||||
if (strcmp(s, "balance-power") == 0)
|
||||
return OPTARG_BALANCE_POWER;
|
||||
|
||||
if (!strncmp(s, "balance-performance", 19))
|
||||
if (strcmp(s, "balance-performance") == 0)
|
||||
return OPTARG_BALANCE_PERFORMANCE;
|
||||
|
||||
if (!strncmp(s, "performance", 11))
|
||||
if (strcmp(s, "performance") == 0)
|
||||
return OPTARG_PERFORMANCE;
|
||||
|
||||
errno = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user