From 0362e9f54bf72aa84d1850545a27da3af83448eb Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Wed, 28 Aug 2024 14:45:12 +0800 Subject: fix compilation errors(s)/warning(s) of x86_cpuid.c found by using clang 18 with CFLAGS: -Wall link of debian's patches is: https://salsa.debian.org/debian/runit/-/tree/master/debian/patches 0029-fix-ftbfs-with-gcc14.patch x86cpuid.c:7:3: error: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 7 | exit(1); | ^ x86cpuid.c:34:7: error: call to undeclared function 'putchar'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 34 | putchar(c); | ^ x86cpuid.c:37:3: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 37 | printf("-%08x-%08x\n",y[0],y[3]); | ^ x86cpuid.c:37:25: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat] 37 | printf("-%08x-%08x\n",y[0],y[3]); | ~~~~ ^~~~ | %08lx x86cpuid.c:37:30: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat] 37 | printf("-%08x-%08x\n",y[0],y[3]); | ~~~~ ^~~~ | %08lx gcc report: x86cpuid.c:7:3: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] x86cpuid.c:7:3: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] x86cpuid.c:34:7: warning: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] x86cpuid.c:37:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] x86cpuid.c:37:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] x86cpuid.c:37:15: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Wformat=] x86cpuid.c:37:20: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=] --- src/x86cpuid.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/x86cpuid.c b/src/x86cpuid.c index f81c593..5cb6670 100644 --- a/src/x86cpuid.c +++ b/src/x86cpuid.c @@ -1,5 +1,7 @@ /* Public domain. */ +#include +#include #include void nope() @@ -17,10 +19,10 @@ int main() signal(SIGILL,nope); - x[0] = 0; - x[1] = 0; - x[2] = 0; - x[3] = 0; + x[0] = y[0] = 0; + x[1] = y[1] = 0; + x[2] = y[2] = 0; + x[3] = y[3] = 0; asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); if (!x[0]) return 0; @@ -34,7 +36,7 @@ int main() putchar(c); } - printf("-%08x-%08x\n",y[0],y[3]); + printf("-%08lx-%08lx\n",y[0],y[3]); return 0; } -- cgit 1.4.1