semantic/parser: fix compile warning found by sparse

Reference:
https://linux.die.net/man/1/sparse

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-05-30 12:51:09 +08:00 committed by Xiang Xiao
parent f875db41d4
commit fb9b41221d
35 changed files with 67 additions and 19 deletions

View File

@ -31,6 +31,8 @@
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
#include <nuttx/drivers/drivers.h>
#include "bch.h" #include "bch.h"
/**************************************************************************** /****************************************************************************

View File

@ -36,6 +36,7 @@
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
#include "bch.h" #include "bch.h"

View File

@ -31,6 +31,7 @@
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
#include "bch.h" #include "bch.h"

View File

@ -33,6 +33,7 @@
#include <debug.h> #include <debug.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
#include "bch.h" #include "bch.h"

View File

@ -32,6 +32,7 @@
#include <nuttx/init.h> #include <nuttx/init.h>
#include <nuttx/clock.h> #include <nuttx/clock.h>
#include <nuttx/streams.h> #include <nuttx/streams.h>
#include <nuttx/syslog/syslog.h>
#include "syslog.h" #include "syslog.h"

View File

@ -41,6 +41,8 @@
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/mutex.h> #include <nuttx/mutex.h>
#include "driver.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && \ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && \
!defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS) !defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS)

View File

@ -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; FAR struct fat_mountpt_s *fs;
int ret; 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, static int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
FAR const char *newrelpath) FAR const char *newrelpath)
{ {
FAR struct fat_mountpt_s *fs; FAR struct fat_mountpt_s *fs;
FAR struct fat_dirinfo_s dirinfo; FAR struct fat_dirinfo_s dirinfo;

View File

@ -652,7 +652,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
errout_with_buffer: errout_with_buffer:
fat_io_free(fs->fs_buffer, fs->fs_hwsectorsize); fat_io_free(fs->fs_buffer, fs->fs_hwsectorsize);
fs->fs_buffer = 0; fs->fs_buffer = NULL;
errout: errout:
fs->fs_mounted = false; fs->fs_mounted = false;

View File

@ -28,6 +28,8 @@
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
#include "fs_anonmap.h"
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/

View File

@ -147,7 +147,7 @@ const struct procfs_operations g_memdump_operations =
}; };
#endif #endif
FAR struct procfs_meminfo_entry_s *g_procfs_meminfo = NULL; static FAR struct procfs_meminfo_entry_s *g_procfs_meminfo = NULL;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions

View File

@ -40,7 +40,7 @@
* Name: file_vioctl * 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; FAR struct inode *inode;
#ifdef CONFIG_FDSAN #ifdef CONFIG_FDSAN

View File

@ -56,6 +56,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/socket.h>
#include <nuttx/net/ethernet.h> #include <nuttx/net/ethernet.h>
@ -247,6 +248,10 @@
* packet size of all enabled link layer protocols. * 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 #if CONFIG_NET_LOOPBACK_PKTSIZE < MAX_NETDEV_PKTSIZE
# define NET_LO_PKTSIZE MAX_NETDEV_PKTSIZE # define NET_LO_PKTSIZE MAX_NETDEV_PKTSIZE
#else #else
@ -254,7 +259,7 @@
#endif #endif
#ifndef CONFIG_NET_SEND_BUFSIZE #ifndef CONFIG_NET_SEND_BUFSIZE
#define CONFIG_NET_SEND_BUFSIZE 0 # define CONFIG_NET_SEND_BUFSIZE 0
#endif #endif
/* Layer 3/4 Configuration Options ******************************************/ /* Layer 3/4 Configuration Options ******************************************/

View File

@ -134,7 +134,8 @@ int note_initialize(void);
#endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */ #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 * Name: note_get_taskname
@ -154,7 +155,9 @@ int note_initialize(void);
int note_get_taskname(pid_t pid, FAR char *name); 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 * Name: note_driver_register

View File

@ -56,7 +56,8 @@
#define NOTERAM_CLEAR _NOTERAMIOC(0x01) #define NOTERAM_CLEAR _NOTERAMIOC(0x01)
#define NOTERAM_GETMODE _NOTERAMIOC(0x02) #define NOTERAM_GETMODE _NOTERAMIOC(0x02)
#define NOTERAM_SETMODE _NOTERAMIOC(0x03) #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) #define NOTERAM_GETTASKNAME _NOTERAMIOC(0x04)
#endif #endif
#endif #endif

View File

@ -212,7 +212,6 @@
#define SNIOC_DISTANCESHORT _SNIOC(0x0060) /* Arg: None */ #define SNIOC_DISTANCESHORT _SNIOC(0x0060) /* Arg: None */
#define SNIOC_DISTANCELONG _SNIOC(0x0061) /* 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 */ #define SNIOC_TEMPUPDATE _SNIOC(0x0063) /* Arg: b16_t value */
/* IOCTL commands unique to the ISL29023 */ /* IOCTL commands unique to the ISL29023 */

View File

@ -468,7 +468,7 @@ static FAR const char *evalexpr(FAR struct eval_s *ev,
return s; 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; struct eval_s ev;

View File

@ -24,6 +24,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <net/ethernet.h> #include <net/ethernet.h>
#include <netinet/ether.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.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 *ether_aton_r(FAR const char *asc,
FAR struct ether_addr *addr) FAR struct ether_addr *addr)
{ {
int i, val0, val1; int i;
int val0;
int val1;
for (i = 0; i < ETHER_ADDR_LEN; ++i) for (i = 0; i < ETHER_ADDR_LEN; ++i)
{ {

View File

@ -27,6 +27,7 @@
#include <nuttx/lib/lib.h> #include <nuttx/lib/lib.h>
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
#include <obstack.h>
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes

View File

@ -25,6 +25,8 @@
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <nuttx/signal.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -25,6 +25,8 @@
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <nuttx/signal.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -25,6 +25,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>

View File

@ -26,6 +26,7 @@
#include <assert.h> #include <assert.h>
#include <nuttx/tls.h> #include <nuttx/tls.h>
#include <nuttx/lib/lib.h>
#ifdef CONFIG_FILE_STREAM #ifdef CONFIG_FILE_STREAM

View File

@ -26,6 +26,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions

View File

@ -24,7 +24,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <strings.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions

View File

@ -27,6 +27,7 @@
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <unistd.h>
#include <termios.h> #include <termios.h>
/**************************************************************************** /****************************************************************************

View File

@ -50,7 +50,7 @@
#define _ALT_E 0x01 #define _ALT_E 0x01
#define _ALT_O 0x02 #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 * Private Data

View File

@ -28,6 +28,8 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include "libc.h"
#ifndef CONFIG_DISABLE_ENVIRON #ifndef CONFIG_DISABLE_ENVIRON
/**************************************************************************** /****************************************************************************

View File

@ -30,6 +30,8 @@
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <sys/resource.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -54,5 +54,5 @@ FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region)
#endif #endif
brkaddr = (uintptr_t)heap->mm_heapend[region]; 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;
} }

View File

@ -27,6 +27,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <nuttx/panic_notifier.h>
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/

View File

@ -24,6 +24,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/notifier.h> #include <nuttx/notifier.h>
#include <nuttx/reboot_notifier.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -33,6 +33,7 @@
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/queue.h> #include <nuttx/queue.h>
#include <nuttx/signal.h>
#include <nuttx/spinlock.h> #include <nuttx/spinlock.h>
#include "sched/sched.h" #include "sched/sched.h"

View File

@ -29,6 +29,8 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/signal.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h" #include "signal/signal.h"

View File

@ -37,7 +37,7 @@
#include "task/task.h" #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 tcb_s *rtcb;
FAR struct task_tcb_s *tcb; FAR struct task_tcb_s *tcb;
@ -205,6 +206,10 @@ errout:
return ret; return ret;
} }
/****************************************************************************
* Public Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: task_restart * Name: task_restart
* *
@ -228,7 +233,6 @@ errout:
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_BUILD_KERNEL
int task_restart(pid_t pid) int task_restart(pid_t pid)
{ {
int ret = nxtask_restart(pid); int ret = nxtask_restart(pid);

View File

@ -61,6 +61,10 @@ class SymbolTables(object):
self.emitline("#include <nuttx/compiler.h>") self.emitline("#include <nuttx/compiler.h>")
self.emitline("#include <nuttx/symtab.h>\n") 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 int g_nallsyms = %d + 2;" % (noconst, len(self.symbol_list)))
self.emitline( self.emitline(
"%s struct symtab_s g_allsyms[%d + 2] =\n{" "%s struct symtab_s g_allsyms[%d + 2] =\n{"