From 0a63ef2a6123f579692b958a3d6666b827dfdb21 Mon Sep 17 00:00:00 2001 From: Peppe289 Date: Mon, 6 Feb 2023 11:39:50 +0100 Subject: [PATCH] cpuid.c: cpuid_load_family(): use string functions for the macro 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 --- lib/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cpuid.c b/lib/cpuid.c index 72e77a94..8a6e0748 100644 --- a/lib/cpuid.c +++ b/lib/cpuid.c @@ -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; }