This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit fb9b41221dd4a930dc76ea986008431c9503c07e
Author: chao an <[email protected]>
AuthorDate: Tue May 30 12:51:09 2023 +0800

    semantic/parser: fix compile warning found by sparse
    
    Reference:
    https://linux.die.net/man/1/sparse
    
    Signed-off-by: chao an <[email protected]>
---
 drivers/bch/bchlib_read.c              |  2 ++
 drivers/bch/bchlib_setup.c             |  1 +
 drivers/bch/bchlib_teardown.c          |  1 +
 drivers/bch/bchlib_write.c             |  1 +
 drivers/syslog/vsyslog.c               |  1 +
 fs/driver/fs_blockproxy.c              |  2 ++
 fs/fat/fs_fat32.c                      |  6 +++---
 fs/fat/fs_fat32util.c                  |  2 +-
 fs/mmap/fs_anonmap.c                   |  2 ++
 fs/procfs/fs_procfsmeminfo.c           |  2 +-
 fs/vfs/fs_ioctl.c                      |  2 +-
 include/nuttx/net/netconfig.h          |  7 ++++++-
 include/nuttx/note/note_driver.h       |  7 +++++--
 include/nuttx/note/noteram_driver.h    |  3 ++-
 include/nuttx/sensors/ioctl.h          |  1 -
 libs/libc/locale/lib_gettext.c         |  2 +-
 libs/libc/net/lib_etheraton.c          |  5 ++++-
 libs/libc/obstack/lib_obstack_malloc.c |  1 +
 libs/libc/signal/sig_nandset.c         |  2 ++
 libs/libc/signal/sig_xorset.c          |  2 ++
 libs/libc/stdio/lib_libfilelock.c      |  1 +
 libs/libc/stdio/lib_libgetstreams.c    |  1 +
 libs/libc/stdio/lib_remove.c           |  1 +
 libs/libc/string/lib_bzero.c           |  2 +-
 libs/libc/termios/lib_isatty.c         |  1 +
 libs/libc/time/lib_strptime.c          |  2 +-
 libs/libc/unistd/lib_restoredir.c      |  2 ++
 libs/libc/unistd/lib_setpriority.c     |  2 ++
 mm/mm_heap/mm_brkaddr.c                |  2 +-
 sched/misc/panic_notifier.c            |  2 ++
 sched/misc/reboot_notifier.c           |  1 +
 sched/signal/sig_action.c              |  1 +
 sched/signal/sig_kill.c                |  2 ++
 sched/task/task_restart.c              | 10 +++++++---
 tools/mkallsyms.py                     |  4 ++++
 35 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c
index 7c6b6239a8..69b8c6c70c 100644
--- a/drivers/bch/bchlib_read.c
+++ b/drivers/bch/bchlib_read.c
@@ -31,6 +31,8 @@
 #include <assert.h>
 #include <debug.h>
 
+#include <nuttx/drivers/drivers.h>
+
 #include "bch.h"
 
 /****************************************************************************
diff --git a/drivers/bch/bchlib_setup.c b/drivers/bch/bchlib_setup.c
index 2d37f06607..aac92ce519 100644
--- a/drivers/bch/bchlib_setup.c
+++ b/drivers/bch/bchlib_setup.c
@@ -36,6 +36,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/fs/fs.h>
+#include <nuttx/drivers/drivers.h>
 
 #include "bch.h"
 
diff --git a/drivers/bch/bchlib_teardown.c b/drivers/bch/bchlib_teardown.c
index 4048cd3fa5..f85b96beef 100644
--- a/drivers/bch/bchlib_teardown.c
+++ b/drivers/bch/bchlib_teardown.c
@@ -31,6 +31,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/fs/fs.h>
+#include <nuttx/drivers/drivers.h>
 
 #include "bch.h"
 
diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c
index 8944cae9d7..dd74adcfa3 100644
--- a/drivers/bch/bchlib_write.c
+++ b/drivers/bch/bchlib_write.c
@@ -33,6 +33,7 @@
 #include <debug.h>
 
 #include <nuttx/fs/fs.h>
+#include <nuttx/drivers/drivers.h>
 
 #include "bch.h"
 
diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c
index 7729e463ac..ef18dd1f49 100644
--- a/drivers/syslog/vsyslog.c
+++ b/drivers/syslog/vsyslog.c
@@ -32,6 +32,7 @@
 #include <nuttx/init.h>
 #include <nuttx/clock.h>
 #include <nuttx/streams.h>
+#include <nuttx/syslog/syslog.h>
 
 #include "syslog.h"
 
diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c
index 4f87a0021e..048da735c7 100644
--- a/fs/driver/fs_blockproxy.c
+++ b/fs/driver/fs_blockproxy.c
@@ -41,6 +41,8 @@
 #include <nuttx/fs/fs.h>
 #include <nuttx/mutex.h>
 
+#include "driver.h"
+
 #if !defined(CONFIG_DISABLE_MOUNTPOINT) && \
     !defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS)
 
diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c
index ccbe16b90d..ae182fed7a 100644
--- a/fs/fat/fs_fat32.c
+++ b/fs/fat/fs_fat32.c
@@ -2644,7 +2644,7 @@ errout_with_lock:
  *
  ****************************************************************************/
 
-int fat_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
+static int fat_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
 {
   FAR struct fat_mountpt_s *fs;
   int ret;
@@ -2692,8 +2692,8 @@ int fat_rmdir(FAR struct inode *mountpt, FAR const char 
*relpath)
  *
  ****************************************************************************/
 
-int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
-               FAR const char *newrelpath)
+static int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
+                      FAR const char *newrelpath)
 {
   FAR struct fat_mountpt_s *fs;
   FAR struct fat_dirinfo_s dirinfo;
diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c
index 6d13561ded..1831e9fc29 100644
--- a/fs/fat/fs_fat32util.c
+++ b/fs/fat/fs_fat32util.c
@@ -652,7 +652,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
 
 errout_with_buffer:
   fat_io_free(fs->fs_buffer, fs->fs_hwsectorsize);
-  fs->fs_buffer = 0;
+  fs->fs_buffer = NULL;
 
 errout:
   fs->fs_mounted = false;
diff --git a/fs/mmap/fs_anonmap.c b/fs/mmap/fs_anonmap.c
index aca25ca1e6..ad86923ab7 100644
--- a/fs/mmap/fs_anonmap.c
+++ b/fs/mmap/fs_anonmap.c
@@ -28,6 +28,8 @@
 #include <assert.h>
 #include <debug.h>
 
+#include "fs_anonmap.h"
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c
index 77abb8bd34..df95244d65 100644
--- a/fs/procfs/fs_procfsmeminfo.c
+++ b/fs/procfs/fs_procfsmeminfo.c
@@ -147,7 +147,7 @@ const struct procfs_operations g_memdump_operations =
 };
 #endif
 
-FAR struct procfs_meminfo_entry_s *g_procfs_meminfo = NULL;
+static FAR struct procfs_meminfo_entry_s *g_procfs_meminfo = NULL;
 
 /****************************************************************************
  * Private Functions
diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c
index 8788f6b280..dfd2b03801 100644
--- a/fs/vfs/fs_ioctl.c
+++ b/fs/vfs/fs_ioctl.c
@@ -40,7 +40,7 @@
  * Name: file_vioctl
  ****************************************************************************/
 
-int file_vioctl(FAR struct file *filep, int req, va_list ap)
+static int file_vioctl(FAR struct file *filep, int req, va_list ap)
 {
   FAR struct inode *inode;
 #ifdef CONFIG_FDSAN
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 1573a3588e..d6055bef13 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -56,6 +56,7 @@
 
 #include <stdint.h>
 #include <sys/param.h>
+#include <sys/socket.h>
 
 #include <nuttx/net/ethernet.h>
 
@@ -247,6 +248,10 @@
  * packet size of all enabled link layer protocols.
  */
 
+#ifndef CONFIG_NET_LOOPBACK_PKTSIZE
+#  define CONFIG_NET_LOOPBACK_PKTSIZE 0
+#endif
+
 #if CONFIG_NET_LOOPBACK_PKTSIZE < MAX_NETDEV_PKTSIZE
 #  define NET_LO_PKTSIZE        MAX_NETDEV_PKTSIZE
 #else
@@ -254,7 +259,7 @@
 #endif
 
 #ifndef CONFIG_NET_SEND_BUFSIZE
-#define CONFIG_NET_SEND_BUFSIZE 0
+#  define CONFIG_NET_SEND_BUFSIZE 0
 #endif
 
 /* Layer 3/4 Configuration Options ******************************************/
diff --git a/include/nuttx/note/note_driver.h b/include/nuttx/note/note_driver.h
index fe30b94864..70d8617a45 100644
--- a/include/nuttx/note/note_driver.h
+++ b/include/nuttx/note/note_driver.h
@@ -134,7 +134,8 @@ int note_initialize(void);
 
 #endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */
 
-#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
+#if defined(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) && \
+    CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
 
 /****************************************************************************
  * Name: note_get_taskname
@@ -154,7 +155,9 @@ int note_initialize(void);
 
 int note_get_taskname(pid_t pid, FAR char *name);
 
-#endif /* CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 */
+#endif /* defined(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) && \
+        * CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
+        */
 
 /****************************************************************************
  * Name: note_driver_register
diff --git a/include/nuttx/note/noteram_driver.h 
b/include/nuttx/note/noteram_driver.h
index 0dad700cdb..5690d772a0 100644
--- a/include/nuttx/note/noteram_driver.h
+++ b/include/nuttx/note/noteram_driver.h
@@ -56,7 +56,8 @@
 #define NOTERAM_CLEAR           _NOTERAMIOC(0x01)
 #define NOTERAM_GETMODE         _NOTERAMIOC(0x02)
 #define NOTERAM_SETMODE         _NOTERAMIOC(0x03)
-#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
+#if defined(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) && \
+    CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
 #define NOTERAM_GETTASKNAME     _NOTERAMIOC(0x04)
 #endif
 #endif
diff --git a/include/nuttx/sensors/ioctl.h b/include/nuttx/sensors/ioctl.h
index 94bd1b911f..d0085f63b5 100644
--- a/include/nuttx/sensors/ioctl.h
+++ b/include/nuttx/sensors/ioctl.h
@@ -212,7 +212,6 @@
 
 #define SNIOC_DISTANCESHORT        _SNIOC(0x0060) /* Arg: None */
 #define SNIOC_DISTANCELONG         _SNIOC(0x0061) /* Arg: None */
-#define SNIOC_CALIBRATE            _SNIOC(0x0062) /* Arg: b16_t value */
 #define SNIOC_TEMPUPDATE           _SNIOC(0x0063) /* Arg: b16_t value */
 
 /* IOCTL commands unique to the ISL29023 */
diff --git a/libs/libc/locale/lib_gettext.c b/libs/libc/locale/lib_gettext.c
index e5835f1d14..cbeeba0b65 100644
--- a/libs/libc/locale/lib_gettext.c
+++ b/libs/libc/locale/lib_gettext.c
@@ -468,7 +468,7 @@ static FAR const char *evalexpr(FAR struct eval_s *ev,
   return s;
 }
 
-unsigned long eval(FAR const char *s, unsigned long n)
+static unsigned long eval(FAR const char *s, unsigned long n)
 {
   struct eval_s ev;
 
diff --git a/libs/libc/net/lib_etheraton.c b/libs/libc/net/lib_etheraton.c
index faf93dc409..aab68f471e 100644
--- a/libs/libc/net/lib_etheraton.c
+++ b/libs/libc/net/lib_etheraton.c
@@ -24,6 +24,7 @@
 
 #include <nuttx/config.h>
 #include <net/ethernet.h>
+#include <netinet/ether.h>
 
 #include <ctype.h>
 #include <stdio.h>
@@ -75,7 +76,9 @@ static inline int xdigit(char c)
 FAR struct ether_addr *ether_aton_r(FAR const char *asc,
                                     FAR struct ether_addr *addr)
 {
-  int i, val0, val1;
+  int i;
+  int val0;
+  int val1;
 
   for (i = 0; i < ETHER_ADDR_LEN; ++i)
     {
diff --git a/libs/libc/obstack/lib_obstack_malloc.c 
b/libs/libc/obstack/lib_obstack_malloc.c
index 9ff028b575..71c2a76e52 100644
--- a/libs/libc/obstack/lib_obstack_malloc.c
+++ b/libs/libc/obstack/lib_obstack_malloc.c
@@ -27,6 +27,7 @@
 #include <nuttx/lib/lib.h>
 #include <assert.h>
 #include <debug.h>
+#include <obstack.h>
 
 /****************************************************************************
  * Private Function Prototypes
diff --git a/libs/libc/signal/sig_nandset.c b/libs/libc/signal/sig_nandset.c
index 9f6cba7671..b5b8d9a242 100644
--- a/libs/libc/signal/sig_nandset.c
+++ b/libs/libc/signal/sig_nandset.c
@@ -25,6 +25,8 @@
 #include <signal.h>
 #include <errno.h>
 
+#include <nuttx/signal.h>
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
diff --git a/libs/libc/signal/sig_xorset.c b/libs/libc/signal/sig_xorset.c
index 1b22d19de2..cec9d219d4 100644
--- a/libs/libc/signal/sig_xorset.c
+++ b/libs/libc/signal/sig_xorset.c
@@ -25,6 +25,8 @@
 #include <signal.h>
 #include <errno.h>
 
+#include <nuttx/signal.h>
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
diff --git a/libs/libc/stdio/lib_libfilelock.c 
b/libs/libc/stdio/lib_libfilelock.c
index ded1f530fd..f13c5b8dce 100644
--- a/libs/libc/stdio/lib_libfilelock.c
+++ b/libs/libc/stdio/lib_libfilelock.c
@@ -25,6 +25,7 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <assert.h>
diff --git a/libs/libc/stdio/lib_libgetstreams.c 
b/libs/libc/stdio/lib_libgetstreams.c
index cb3025f60a..c86fbb0d18 100644
--- a/libs/libc/stdio/lib_libgetstreams.c
+++ b/libs/libc/stdio/lib_libgetstreams.c
@@ -26,6 +26,7 @@
 #include <assert.h>
 
 #include <nuttx/tls.h>
+#include <nuttx/lib/lib.h>
 
 #ifdef CONFIG_FILE_STREAM
 
diff --git a/libs/libc/stdio/lib_remove.c b/libs/libc/stdio/lib_remove.c
index 30ad02fe87..7798d6cbfc 100644
--- a/libs/libc/stdio/lib_remove.c
+++ b/libs/libc/stdio/lib_remove.c
@@ -26,6 +26,7 @@
 
 #include <sys/stat.h>
 #include <unistd.h>
+#include <stdio.h>
 
 /****************************************************************************
  * Public Functions
diff --git a/libs/libc/string/lib_bzero.c b/libs/libc/string/lib_bzero.c
index 33b39fdb03..a0dfeace4e 100644
--- a/libs/libc/string/lib_bzero.c
+++ b/libs/libc/string/lib_bzero.c
@@ -24,7 +24,7 @@
 
 #include <nuttx/config.h>
 #include <sys/types.h>
-#include <string.h>
+#include <strings.h>
 
 /****************************************************************************
  * Public Functions
diff --git a/libs/libc/termios/lib_isatty.c b/libs/libc/termios/lib_isatty.c
index b3b236c248..b88e75b187 100644
--- a/libs/libc/termios/lib_isatty.c
+++ b/libs/libc/termios/lib_isatty.c
@@ -27,6 +27,7 @@
  * Included Files
  ****************************************************************************/
 
+#include <unistd.h>
 #include <termios.h>
 
 /****************************************************************************
diff --git a/libs/libc/time/lib_strptime.c b/libs/libc/time/lib_strptime.c
index 789076858d..407ea911fb 100644
--- a/libs/libc/time/lib_strptime.c
+++ b/libs/libc/time/lib_strptime.c
@@ -50,7 +50,7 @@
 
 #define _ALT_E              0x01
 #define _ALT_O              0x02
-#define _LEGAL_ALT(x)       { if (alt_format & ~(x)) return (0); }
+#define _LEGAL_ALT(x)       { if (alt_format & ~(x)) return (NULL); }
 
 /****************************************************************************
  * Private Data
diff --git a/libs/libc/unistd/lib_restoredir.c 
b/libs/libc/unistd/lib_restoredir.c
index e86f2f3693..2a7a49372d 100644
--- a/libs/libc/unistd/lib_restoredir.c
+++ b/libs/libc/unistd/lib_restoredir.c
@@ -28,6 +28,8 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "libc.h"
+
 #ifndef CONFIG_DISABLE_ENVIRON
 
 /****************************************************************************
diff --git a/libs/libc/unistd/lib_setpriority.c 
b/libs/libc/unistd/lib_setpriority.c
index 501973d0b1..96213a82a2 100644
--- a/libs/libc/unistd/lib_setpriority.c
+++ b/libs/libc/unistd/lib_setpriority.c
@@ -30,6 +30,8 @@
 
 #include <nuttx/sched.h>
 
+#include <sys/resource.h>
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
diff --git a/mm/mm_heap/mm_brkaddr.c b/mm/mm_heap/mm_brkaddr.c
index afc02b9ce4..37d6d61d1e 100644
--- a/mm/mm_heap/mm_brkaddr.c
+++ b/mm/mm_heap/mm_brkaddr.c
@@ -54,5 +54,5 @@ FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region)
 #endif
 
   brkaddr = (uintptr_t)heap->mm_heapend[region];
-  return brkaddr ? (FAR void *)(brkaddr + SIZEOF_MM_ALLOCNODE) : 0;
+  return brkaddr ? (FAR void *)(brkaddr + SIZEOF_MM_ALLOCNODE) : NULL;
 }
diff --git a/sched/misc/panic_notifier.c b/sched/misc/panic_notifier.c
index a8ae3b3f79..0cb67930b4 100644
--- a/sched/misc/panic_notifier.c
+++ b/sched/misc/panic_notifier.c
@@ -27,6 +27,8 @@
 
 #include <sys/types.h>
 
+#include <nuttx/panic_notifier.h>
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
diff --git a/sched/misc/reboot_notifier.c b/sched/misc/reboot_notifier.c
index 1e2023954b..616efbeb27 100644
--- a/sched/misc/reboot_notifier.c
+++ b/sched/misc/reboot_notifier.c
@@ -24,6 +24,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/notifier.h>
+#include <nuttx/reboot_notifier.h>
 
 #include <sys/types.h>
 
diff --git a/sched/signal/sig_action.c b/sched/signal/sig_action.c
index cf16f98a14..934a668224 100644
--- a/sched/signal/sig_action.c
+++ b/sched/signal/sig_action.c
@@ -33,6 +33,7 @@
 
 #include <nuttx/irq.h>
 #include <nuttx/queue.h>
+#include <nuttx/signal.h>
 #include <nuttx/spinlock.h>
 
 #include "sched/sched.h"
diff --git a/sched/signal/sig_kill.c b/sched/signal/sig_kill.c
index 66dce9ea0d..3b6d6f09ed 100644
--- a/sched/signal/sig_kill.c
+++ b/sched/signal/sig_kill.c
@@ -29,6 +29,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/signal.h>
+
 #include "sched/sched.h"
 #include "signal/signal.h"
 
diff --git a/sched/task/task_restart.c b/sched/task/task_restart.c
index e3f9f573f8..cb722f44fe 100644
--- a/sched/task/task_restart.c
+++ b/sched/task/task_restart.c
@@ -37,7 +37,7 @@
 #include "task/task.h"
 
 /****************************************************************************
- * Public Functions
+ * Private Functions
  ****************************************************************************/
 
 /****************************************************************************
@@ -62,7 +62,8 @@
  *
  ****************************************************************************/
 
-int nxtask_restart(pid_t pid)
+#ifndef CONFIG_BUILD_KERNEL
+static int nxtask_restart(pid_t pid)
 {
   FAR struct tcb_s *rtcb;
   FAR struct task_tcb_s *tcb;
@@ -205,6 +206,10 @@ errout:
   return ret;
 }
 
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
 /****************************************************************************
  * Name: task_restart
  *
@@ -228,7 +233,6 @@ errout:
  *
  ****************************************************************************/
 
-#ifndef CONFIG_BUILD_KERNEL
 int task_restart(pid_t pid)
 {
   int ret = nxtask_restart(pid);
diff --git a/tools/mkallsyms.py b/tools/mkallsyms.py
index 00fad94b98..46721d50ec 100755
--- a/tools/mkallsyms.py
+++ b/tools/mkallsyms.py
@@ -61,6 +61,10 @@ class SymbolTables(object):
 
         self.emitline("#include <nuttx/compiler.h>")
         self.emitline("#include <nuttx/symtab.h>\n")
+        self.emitline("extern int g_nallsyms;\n")
+        self.emitline(
+            "extern struct symtab_s g_allsyms[%d + 2];\n" % 
len(self.symbol_list)
+        )
         self.emitline("%s int g_nallsyms = %d + 2;" % (noconst, 
len(self.symbol_list)))
         self.emitline(
             "%s struct symtab_s g_allsyms[%d + 2] =\n{"

Reply via email to