Skip to content

Commit

Permalink
cpuid.c: cpuid_load_family(): use string functions for the macro
Browse files Browse the repository at this point in the history
the CPUID_VENDOR_AMD macro is a string.
With sizeof() we count every single character that is 1, including the character at the end of the string '\0'.
With strlen() instead we calculate only the useful characters before '\0'.

Signed-off-by: Peppe289 <[email protected]>
  • Loading branch information
Peppe289 authored and FlyGoat committed Feb 15, 2023
1 parent 280a068 commit 0a63ef2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static enum ryzen_family cpuid_load_family()
*(uint32_t *) &vendor[4] = regs[3];
*(uint32_t *) &vendor[8] = regs[2];

if (strncmp(vendor, CPUID_VENDOR_AMD, sizeof(CPUID_VENDOR_AMD) - 1)) {
if (strncmp(vendor, CPUID_VENDOR_AMD, strlen(CPUID_VENDOR_AMD))) {
printf("Not AMD processor, must be kidding\n");
return FAM_UNKNOWN;
}
Expand Down

0 comments on commit 0a63ef2

Please sign in to comment.