Linux - Why doesn't a custom system call work properly with negative numbers?
问题 I wrote a custom system call that compares two integers and returns the biggest one. Here's my kernel-side code: max.c #include <linux/kernel.h> #include <linux/syscalls.h> asmlinkage long sys_max(int num1, int num2) { if (num1 > num2) { return num1; } else { return num2; } } And here's my user-space code: max.h #include <unistd.h> #define SYS_MAX 323 int max(int num1, int num2) { int maxnumber = syscall(SYS_MAX, num1, num2); return maxnumber; } I'm using this little program to test the