]> Gentwo Git Trees - linux/.git/commitdiff
tools/nolibc: avoid using plain integer as NULL pointer
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 9 Nov 2025 19:27:29 +0000 (20:27 +0100)
committerThomas Weißschuh <linux@weissschuh.net>
Sun, 9 Nov 2025 20:29:57 +0000 (21:29 +0100)
While an integer zero is a valid NULL pointer as per the C standard,
sparse will complain about it.

Use explicit NULL pointers instead.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202509261452.g5peaXCc-lkp@intel.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
tools/include/nolibc/getopt.h
tools/include/nolibc/sys.h
tools/include/nolibc/sys/reboot.h
tools/include/nolibc/unistd.h

index 217abb95264b286a9f6bcd500779575a9a508352..87565e3b6a339fad6d49f2ae906f2826144f79f7 100644 (file)
@@ -78,7 +78,7 @@ int getopt(int argc, char * const argv[], const char *optstring)
                return '?';
        }
        if (optstring[i] == ':') {
-               optarg = 0;
+               optarg = NULL;
                if (optstring[i + 1] != ':' || __optpos) {
                        optarg = argv[optind++];
                        if (__optpos)
index 28481feedb37217b43270bce545ec5cfae05553f..fcc36cffad4db19c418b206f0556e3ab39c9a89d 100644 (file)
@@ -106,7 +106,7 @@ static __attribute__((unused))
 void *sbrk(intptr_t inc)
 {
        /* first call to find current end */
-       void *ret = sys_brk(0);
+       void *ret = sys_brk(NULL);
 
        if (ret && sys_brk(ret + inc) == ret + inc)
                return ret + inc;
index 4a1e435be66966fbb136e6a4aee1b0676aefb3b0..38274c64a7228c7dc648f89952d17523e138e420 100644 (file)
@@ -28,7 +28,7 @@ ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
 static __attribute__((unused))
 int reboot(int cmd)
 {
-       return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0));
+       return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, NULL));
 }
 
 #endif /* _NOLIBC_SYS_REBOOT_H */
index 7405fa2b89baa805d0ab1d28ae70c9d8c1ef67a7..bb5e80f3f05d5490263326ca561f9d1aa9df6151 100644 (file)
@@ -54,7 +54,7 @@ int msleep(unsigned int msecs)
 {
        struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 };
 
-       if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
+       if (sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
                return (my_timeval.tv_sec * 1000) +
                        (my_timeval.tv_usec / 1000) +
                        !!(my_timeval.tv_usec % 1000);
@@ -67,7 +67,7 @@ unsigned int sleep(unsigned int seconds)
 {
        struct timeval my_timeval = { seconds, 0 };
 
-       if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
+       if (sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
                return my_timeval.tv_sec + !!my_timeval.tv_usec;
        else
                return 0;
@@ -78,7 +78,7 @@ int usleep(unsigned int usecs)
 {
        struct timeval my_timeval = { usecs / 1000000, usecs % 1000000 };
 
-       return sys_select(0, 0, 0, 0, &my_timeval);
+       return sys_select(0, NULL, NULL, NULL, &my_timeval);
 }
 
 static __attribute__((unused))