From b45d4a865e21fb05c1843b8b668bd32f6825e36d Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 9 Mar 2025 14:10:17 +0300 Subject: [PATCH] cpuid_vendor_id.mod.c: don't waste 1 `char` for convenience --- c-programming/sys/cpuid_vendor_id.mod.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/c-programming/sys/cpuid_vendor_id.mod.c b/c-programming/sys/cpuid_vendor_id.mod.c index 9e722bf..89232a2 100644 --- a/c-programming/sys/cpuid_vendor_id.mod.c +++ b/c-programming/sys/cpuid_vendor_id.mod.c @@ -58,7 +58,7 @@ static inline void native_cpuid(unsigned int function_id, cpuid_t r) { #endif } -#define VENDOR_ID_LEN 13 +#define VENDOR_ID_LEN 12 /* * FIXME: you have to make sure the vendor argument is at least lengthed @@ -74,12 +74,13 @@ static inline void cpuid_vendor_id(char vendor[VENDOR_ID_LEN]) { ((unsigned*) vendor)[0] = v[EBX]; ((unsigned*) vendor)[1] = v[EDX]; ((unsigned*) vendor)[2] = v[ECX]; - vendor[VENDOR_ID_LEN - 1] = '\0'; } int main(void) { char vendor_string[VENDOR_ID_LEN]; cpuid_vendor_id(vendor_string); - printf("CPU Vendor ID: '%s'\n", vendor_string); + fputs("CPU Vendor ID: '", stdout); + fwrite(vendor_string, sizeof(char), 12, stdout); + fputs("'\n", stdout); return 0; }