Skip to contentSkip to conversation

x86/pmu: Fix compilation on macOS

PATCH New Thomas Huth 1 participant 1 message Jul 23, 2025 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pmu: Fix compilation on macOS

From: Thomas Huth <[email protected]>

Compiling for i686 on macOS in the CI currently fails with:

.../cirrus-ci-build/x86/pmu.c: In function 'main':
.../cirrus-ci-build/x86/pmu.c:1012:41: error: format '%x' expects argument of
type 'unsigned int', but argument 2 has type 'u32' {aka 'long unsigned int'} [-Werror=format=]

 1012 |     printf("Arch Events (mask):  0x%x\n", pmu.arch_event_available);
      |                                    ~^     ~~~~~~~~~~~~~~~~~~~~~~~~
      |                                     |        |
      |                                     |        u32 {aka long unsigned int}
      |                                     unsigned int
      |                                    %lx

Use the correct format string for u32 to fix this issue.

Fixes 92dc5f7a ("x86/pmu: Mark Intel architectural event available [...]")
---
 x86/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/pmu.c +1 -1
index a6b0cfcc..f932ccab 100644
@@ -1009,7 +1009,7 @@ int main(int ac, char **av)
 	printf("GP counters:         %d\n", pmu.nr_gp_counters);
 	printf("GP counter width:    %d\n", pmu.gp_counter_width);
 	printf("Event Mask length:   %d\n", pmu.arch_event_mask_length);
-	printf("Arch Events (mask):  0x%x\n", pmu.arch_event_available);
+	printf("Arch Events (mask):  0x%" PRIx32 "\n", pmu.arch_event_available);
 	printf("Fixed counters:      %d\n", pmu.nr_fixed_counters);
 	printf("Fixed counter width: %d\n", pmu.fixed_counter_width);
 
Signature · 1 line
2.50.1