summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorZ. Liu <zhixu.liu@gmail.com>2024-08-28 14:45:12 +0800
committerGerrit Pape <pape@smarden.org>2024-09-25 22:22:00 +0000
commit0362e9f54bf72aa84d1850545a27da3af83448eb (patch)
treec8ee553c0a839bd549d1b11fc97fc9ec666b77b4 /src
parentbb30adfc42b9993a4523fbed9e674fdab5971220 (diff)
downloadrunit-0362e9f54bf72aa84d1850545a27da3af83448eb.tar.gz
runit-0362e9f54bf72aa84d1850545a27da3af83448eb.tar.xz
runit-0362e9f54bf72aa84d1850545a27da3af83448eb.zip
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=]
Diffstat (limited to 'src')
-rw-r--r--src/x86cpuid.c12
1 files 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 <stdio.h>
+#include <stdlib.h>
 #include <signal.h>
 
 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;
 }