More fixes to problems noted by cppcheck. Some are kind of risky; some are real bugs.
This commit is contained in:
parent
2994448d85
commit
9ac09db800
@ -687,7 +687,7 @@ static void * cc3000_worker(FAR void *arg)
|
||||
* Will it fit?
|
||||
*/
|
||||
|
||||
if (data_to_recv >= priv->rx_buffer_max_len
|
||||
if (data_to_recv >= priv->rx_buffer_max_len)
|
||||
{
|
||||
lowsyslog(LOG_INFO, "data_to_recv %d", data_to_recv);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static void aio_read_worker(FAR void *arg)
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
uint8_t prio;
|
||||
#endif
|
||||
ssize_t nread;
|
||||
ssize_t nread = 0;
|
||||
|
||||
/* Get the information from the container, decant the AIO control block,
|
||||
* and free the container before starting any I/O. That will minimize
|
||||
|
@ -113,8 +113,10 @@ static void aio_write_worker(FAR void *arg)
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
uint8_t prio;
|
||||
#endif
|
||||
ssize_t nwritten;
|
||||
ssize_t nwritten = 0;
|
||||
#ifdef AIO_HAVE_FILEP
|
||||
int oflags;
|
||||
#endif
|
||||
|
||||
/* Get the information from the container, decant the AIO control block,
|
||||
* and free the container before starting any I/O. That will minimize
|
||||
|
@ -950,7 +950,7 @@ int mkfatfs_configfatfs(FAR struct fat_format_s *fmt,
|
||||
{
|
||||
/* There must be reserved sectors in order to have a backup boot sector */
|
||||
|
||||
if (fmt->ff_rsvdseccount > 0 && fmt->ff_rsvdseccount >= 2)
|
||||
if (fmt->ff_rsvdseccount >= 2)
|
||||
{
|
||||
/* Sector 0 is the MBR; 1... ff_rsvdseccount are reserved. Try the next
|
||||
* the last reserved sector.
|
||||
|
@ -67,7 +67,9 @@ struct nxffs_blkinfo_s
|
||||
off_t nblocks;
|
||||
off_t block;
|
||||
off_t offset;
|
||||
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS)
|
||||
bool verbose;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -410,7 +410,7 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume)
|
||||
|
||||
if (!noinodes)
|
||||
{
|
||||
while ((ret = nxffs_nextentry(volume, offset, &entry)) == OK)
|
||||
while (nxffs_nextentry(volume, offset, &entry) == OK)
|
||||
{
|
||||
/* Discard the entry and guess the next offset. */
|
||||
|
||||
|
@ -709,7 +709,9 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
|
||||
FAR struct smartfs_file_s *priv;
|
||||
int ret;
|
||||
size_t len;
|
||||
#if 0 /* Not used */
|
||||
int utilization;
|
||||
#endif
|
||||
|
||||
priv = (FAR struct smartfs_file_s *) filep->f_priv;
|
||||
|
||||
@ -729,6 +731,7 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
#if 0 /* Not used */
|
||||
/* Calculate the sector utilization percentage */
|
||||
|
||||
if (procfs_data.blockerases == 0)
|
||||
@ -741,6 +744,7 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
|
||||
procfs_data.unusedsectors) / (procfs_data.blockerases *
|
||||
procfs_data.sectorsperblk);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Format and return data in the buffer */
|
||||
|
||||
@ -756,8 +760,10 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
|
||||
procfs_data.formatsector, procfs_data.dirsector,
|
||||
procfs_data.freesectors, procfs_data.releasesectors,
|
||||
procfs_data.sectorsperblk);
|
||||
//procfs_data.unusedsectors, procfs_data.blockerases,
|
||||
//procfs_data.sectorsperblk, utilization);
|
||||
#if 0 /* Not used */
|
||||
procfs_data.unusedsectors, procfs_data.blockerases,
|
||||
procfs_data.sectorsperblk, utilization);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Indicate we have already provided all the data */
|
||||
|
@ -1441,7 +1441,7 @@ static int smartfs_unbind(void *handle, FAR struct inode **blkdriver)
|
||||
static int smartfs_statfs(struct inode *mountpt, struct statfs *buf)
|
||||
{
|
||||
struct smartfs_mountpt_s *fs;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
@ -1483,11 +1483,11 @@ static int smartfs_statfs(struct inode *mountpt, struct statfs *buf)
|
||||
|
||||
static int smartfs_unlink(struct inode *mountpt, const char *relpath)
|
||||
{
|
||||
struct smartfs_mountpt_s *fs;
|
||||
int ret = OK;
|
||||
struct smartfs_entry_s entry;
|
||||
const char *filename;
|
||||
uint16_t parentdirsector;
|
||||
struct smartfs_mountpt_s *fs;
|
||||
int ret;
|
||||
struct smartfs_entry_s entry;
|
||||
const char *filename;
|
||||
uint16_t parentdirsector;
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
@ -1627,11 +1627,11 @@ errout_with_semaphore:
|
||||
|
||||
int smartfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
{
|
||||
struct smartfs_mountpt_s *fs;
|
||||
int ret = OK;
|
||||
struct smartfs_entry_s entry;
|
||||
const char *filename;
|
||||
uint16_t parentdirsector;
|
||||
struct smartfs_mountpt_s *fs;
|
||||
int ret;
|
||||
struct smartfs_entry_s entry;
|
||||
const char *filename;
|
||||
uint16_t parentdirsector;
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
@ -1916,7 +1916,7 @@ static int smartfs_stat(struct inode *mountpt, const char *relpath, struct stat
|
||||
{
|
||||
struct smartfs_mountpt_s *fs;
|
||||
struct smartfs_entry_s entry;
|
||||
int ret = -ENOENT;
|
||||
int ret;
|
||||
uint16_t parentdirsector;
|
||||
const char *filename;
|
||||
|
||||
|
@ -147,7 +147,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
||||
break;
|
||||
}
|
||||
|
||||
if (numoffset <= 0)
|
||||
if (numoffset < 1)
|
||||
{
|
||||
/* Empty numeric string */
|
||||
|
||||
@ -245,7 +245,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch != '\0' && numoffset <= 0)
|
||||
if (ch != '\0' && numoffset < 1)
|
||||
{
|
||||
/* Empty numeric string */
|
||||
|
||||
|
@ -65,7 +65,7 @@ static int lowinstream_getc(FAR struct lib_instream_s *this)
|
||||
|
||||
/* Get the next character from the incoming stream */
|
||||
|
||||
ret = up_getc(ch)
|
||||
ret = up_getc(ch);
|
||||
if (ret != EOF)
|
||||
{
|
||||
this->nget++;
|
||||
|
@ -149,9 +149,7 @@ static void incr_base62(void)
|
||||
|
||||
static void get_base62(FAR uint8_t *ptr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
while ((ret = sem_wait(&g_b62sem)) < 0)
|
||||
while (sem_wait(&g_b62sem) < 0)
|
||||
{
|
||||
DEBUGASSERT(errno == EINTR);
|
||||
}
|
||||
|
@ -213,6 +213,7 @@ loop:
|
||||
swap(pl, pl - size);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -230,6 +231,7 @@ loop:
|
||||
if ((r = pd - pc) > size)
|
||||
{
|
||||
/* Iterate rather than recurse to save stack space */
|
||||
|
||||
base = pn - r;
|
||||
nmemb = r / size;
|
||||
goto loop;
|
||||
|
@ -91,7 +91,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
|
||||
|
||||
/* Handle bad sizes */
|
||||
|
||||
if (size <= 0)
|
||||
if (size < 1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
||||
|
||||
/* If size is zero, then realloc is equivalent to free */
|
||||
|
||||
if (size <= 0)
|
||||
if (size < 1)
|
||||
{
|
||||
mm_free(heap, oldmem);
|
||||
return NULL;
|
||||
@ -170,7 +170,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
||||
* previous chunk is smaller than the next chunk.
|
||||
*/
|
||||
|
||||
if (prevsize > 0 && (nextsize >= prevsize || nextsize <= 0))
|
||||
if (prevsize > 0 && (nextsize >= prevsize || nextsize < 1))
|
||||
{
|
||||
/* Can we get everything we need from the previous chunk? */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user