More fixes to problems noted by cppcheck. Some are kind of risky; some are real bugs.

This commit is contained in:
Gregory Nutt 2014-11-25 14:10:35 -06:00
parent 9ac09db800
commit 1aa528a572
9 changed files with 9 additions and 14 deletions

View File

@ -151,7 +151,6 @@ int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath,
memset(buf, 0, sizeof(struct stat));
buf->st_blksize = volume->geo.blocksize;
buf->st_blocks = entry.datlen / (volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR);
/* The requested directory must be the volume-relative "root" directory */
@ -166,6 +165,7 @@ int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath,
goto errout_with_semaphore;
}
buf->st_blocks = entry.datlen / (volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR);
buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR;
buf->st_size = entry.datlen;
buf->st_atime = entry.utc;

View File

@ -108,7 +108,7 @@ static inline int vsyslog_internal(FAR const char *fmt, va_list ap)
/* Get the current time */
ret = clock_systimespec(&ts);
(void)clock_systimespec(&ts);
#endif
#if defined(CONFIG_SYSLOG)

View File

@ -146,6 +146,7 @@ int execl(FAR const char *path, ...)
if (++nargs > MAX_EXECL_ARGS)
{
set_errno(E2BIG);
va_end(ap);
return ERROR;
}
}

View File

@ -86,7 +86,6 @@ FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen)
FAR struct iob_s *entry;
FAR struct iob_s *penultimate;
FAR struct iob_s *last;
unsigned int iosize;
int len;
nlldbg("iob=%p pktlen=%d trimlen=%d\n", iob, iob->io_pktlen, trimlen);
@ -105,14 +104,9 @@ FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen)
penultimate = NULL;
last = NULL;
iosize = 0;
for (entry = iob; entry; entry = entry->io_flink)
{
/* Accumulate the total size of all buffers in the list */
iosize += entry->io_len;
/* Remember the last and the next to the last in the chain */
penultimate = last;

View File

@ -163,7 +163,6 @@ void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
#else
net_ipaddr_copy(*router, match.target);
#endif
ret = OK;
}
else
{

View File

@ -341,6 +341,7 @@ void os_start(void)
sem_initialize();
#if defined(MM_KERNEL_USRHEAP_INIT) || defined(CONFIG_MM_KERNEL_HEAP) || defined(CONFIG_MM_PGALLOC)
/* Initialize the memory manager */
{
@ -375,6 +376,7 @@ void os_start(void)
mm_pginitialize(heap_start, heap_size);
#endif
}
#endif
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
/* Initialize tasking data structures */

View File

@ -467,12 +467,9 @@ static void sched_timer_start(unsigned int ticks)
ret = up_timer_start(&ts);
#endif
/* [Re-]start the interval timer */
ret = up_timer_start(&ts);
if (ret < 0)
{
slldbg("ERROR: up_timer_start failed: %d\n");
slldbg("ERROR: up_timer_start/up_alarm_start failed: %d\n");
UNUSED(ret);
}
}

View File

@ -452,7 +452,7 @@ unsigned int wd_timer(int ticks)
/* There are. Decrement the lag counter */
wdog->lag -= decr;
ticks -= ticks;
ticks -= decr;
/* Check if the watchdog at the head of the list is ready to run */

View File

@ -176,9 +176,11 @@ static void lpwork_boostworker(pid_t wpid, uint8_t reqprio)
static void lpwork_restoreworker(pid_t wpid, uint8_t reqprio)
{
FAR struct tcb_s *wtcb;
#if CONFIG_SEM_NNESTPRIO > 0
uint8_t wpriority;
int index;
int selected;
#endif
/* Get the TCB of the low priority worker thread from the process ID. */