From 543c3ac17d9d13a42a66bb88aec2fa66439f5e58 Mon Sep 17 00:00:00 2001 From: The Tumultuous Unicorn Of Darkness Date: Wed, 31 Jul 2024 14:32:15 +0200 Subject: [PATCH] Fix scanf() format for 'logical_cpu' in cpuid_deserialize_raw_data_internal() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit logical_cpu is an uint16_t, so SCNu16 is the correct format. It was providing strange values with SCNi16, like with the Intel® Xeon® Platinum 8280 dump. --- libcpuid/cpuid_main.c | 8 ++++---- .../x86-64/skylake/cascade-lake-sp-xeon-platinum.test | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libcpuid/cpuid_main.c b/libcpuid/cpuid_main.c index a2b882e..6df9990 100644 --- a/libcpuid/cpuid_main.c +++ b/libcpuid/cpuid_main.c @@ -806,7 +806,7 @@ static int cpuid_deserialize_raw_data_internal(struct cpu_raw_data_t* single_raw } if (is_libcpuid_dump) { - if (use_raw_array && (sscanf(line, "_________________ Logical CPU #%" SCNi16 " _________________", &logical_cpu) >= 1)) { + if (use_raw_array && (sscanf(line, "_________________ Logical CPU #%" SCNu16 " _________________", &logical_cpu) >= 1)) { debugf(2, "Parsing raw dump for logical CPU %i\n", logical_cpu); is_header = false; cpuid_grow_raw_data_array(raw_array, logical_cpu + 1); @@ -887,9 +887,9 @@ static int cpuid_deserialize_raw_data_internal(struct cpu_raw_data_t* single_raw } } else if (is_aida64_dump) { - if (use_raw_array && ((sscanf(line, "------[ Logical CPU #%" SCNi16 " ]------", &logical_cpu) >= 1) || - (sscanf(line, "------[ CPUID Registers / Logical CPU #%" SCNi16 " ]------", &logical_cpu) >= 1) || - (sscanf(line, "CPU#%" SCNi16 " AffMask: 0x%*x", &logical_cpu) >= 1))) { + if (use_raw_array && ((sscanf(line, "------[ Logical CPU #%" SCNu16 " ]------", &logical_cpu) >= 1) || + (sscanf(line, "------[ CPUID Registers / Logical CPU #%" SCNu16 " ]------", &logical_cpu) >= 1) || + (sscanf(line, "CPU#%" SCNu16 " AffMask: 0x%*x", &logical_cpu) >= 1))) { debugf(2, "Parsing AIDA64 raw dump for logical CPU %i\n", logical_cpu); cpuid_grow_raw_data_array(raw_array, logical_cpu + 1); raw_ptr = &raw_array->raw[logical_cpu]; diff --git a/tests/intel/x86-64/skylake/cascade-lake-sp-xeon-platinum.test b/tests/intel/x86-64/skylake/cascade-lake-sp-xeon-platinum.test index e688b73..499d49d 100644 --- a/tests/intel/x86-64/skylake/cascade-lake-sp-xeon-platinum.test +++ b/tests/intel/x86-64/skylake/cascade-lake-sp-xeon-platinum.test @@ -2751,8 +2751,8 @@ general 7 6 85 -26 -46 +28 +56 32 32 1024 @@ -2768,9 +2768,9 @@ general 64 64 -1 -26 -26 -26 +28 +28 +28 1 0 128 (non-authoritative)