Fixes for more complaints from cppcheck
This commit is contained in:
parent
6d63658c46
commit
b5c4fbf7b6
@ -219,11 +219,6 @@ int main(int argc, char *argv[])
|
||||
goto errout_with_recvsd;
|
||||
}
|
||||
|
||||
if (nrecvd != nrecvd)
|
||||
{
|
||||
fprintf(stderr, LABEL "ERROR: Number of bytes received differs from number sent\n");
|
||||
}
|
||||
|
||||
/* Dump the received packet */
|
||||
|
||||
for (i = 0, j = 0; i < nrecvd; i++)
|
||||
|
@ -404,7 +404,9 @@ int buttons_main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t newset;
|
||||
irqstate_t flags;
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
int i;
|
||||
#endif
|
||||
|
||||
/* If this example is configured as an NX add-on, then limit the number of
|
||||
* samples that we collect before returning. Otherwise, we never return
|
||||
@ -425,7 +427,7 @@ int buttons_main(int argc, char *argv[])
|
||||
|
||||
board_button_initialize();
|
||||
|
||||
/* Register to recieve button interrupts */
|
||||
/* Register to receive button interrupts */
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
|
||||
@ -496,7 +498,7 @@ int buttons_main(int argc, char *argv[])
|
||||
|
||||
/* Un-register button handlers */
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NSH_BUILTIN_APPS)
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
|
||||
{
|
||||
(void)board_button_irq(i, NULL);
|
||||
|
@ -201,7 +201,7 @@ static int telnetd_daemon(int argc, char *argv[])
|
||||
|
||||
nllvdbg("Creating the telnet driver\n");
|
||||
devpath = telnetd_driver(acceptsd, daemon);
|
||||
if (devpath < 0)
|
||||
if (devpath == NULL)
|
||||
{
|
||||
nlldbg("telnetd_driver failed\n");
|
||||
goto errout_with_acceptsd;
|
||||
|
@ -76,29 +76,29 @@ void thread_func(void *parameter)
|
||||
for (i = 0; i < 20 && !bendoftest; i++);
|
||||
{
|
||||
if ((pthread_mutex_lock(&mut)) != 0)
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_lock failed\n", my_id);
|
||||
}
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_lock failed\n", my_id);
|
||||
}
|
||||
|
||||
if (my_mutex == 1)
|
||||
{
|
||||
printf("ERROR thread=%d: "
|
||||
"my_mutex should be zero, instead my_mutex=%d\n",
|
||||
my_id, my_mutex);
|
||||
nerrors[my_ndx]++;
|
||||
}
|
||||
{
|
||||
printf("ERROR thread=%d: "
|
||||
"my_mutex should be zero, instead my_mutex=%d\n",
|
||||
my_id, my_mutex);
|
||||
nerrors[my_ndx]++;
|
||||
}
|
||||
|
||||
my_mutex = 1;
|
||||
usleep(100000);
|
||||
my_mutex = 0;
|
||||
|
||||
|
||||
if ((pthread_mutex_unlock(&mut)) != 0)
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_unlock failed\n", my_id);
|
||||
}
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_unlock failed\n", my_id);
|
||||
}
|
||||
|
||||
nloops[my_ndx]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -141,9 +141,8 @@ int main(int argc, char **argv)
|
||||
pthread_join(thread2, NULL);
|
||||
|
||||
printf("\tThread1\tThread2\n");
|
||||
printf("Loops\t%ld\t%ld\n", nloops[0], nloops[1]);
|
||||
printf("Errors\t%ld\t%ld\n", nerrors[0], nerrors[1]);
|
||||
printf("Loops\t%lu\t%lu\n", nloops[0], nloops[1]);
|
||||
printf("Errors\t%lu\t%lu\n", nerrors[0], nerrors[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ int cmd_rrename(SESSION handle, int argc, char **argv)
|
||||
int cmd_rsize(SESSION handle, int argc, char **argv)
|
||||
{
|
||||
off_t size = ftpc_filesize(handle, argv[1]);
|
||||
printf("SIZE: %lu\n", size);
|
||||
printf("SIZE: %lu\n", (unsigned long)size);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -126,16 +126,16 @@ static void mm_showmallinfo(void)
|
||||
{
|
||||
alloc_info = mallinfo();
|
||||
printf(" mallinfo:\n");
|
||||
printf(" Total space allocated from system = %ld\n",
|
||||
alloc_info.arena);
|
||||
printf(" Number of non-inuse chunks = %ld\n",
|
||||
alloc_info.ordblks);
|
||||
printf(" Largest non-inuse chunk = %ld\n",
|
||||
alloc_info.mxordblk);
|
||||
printf(" Total allocated space = %ld\n",
|
||||
alloc_info.uordblks);
|
||||
printf(" Total non-inuse space = %ld\n",
|
||||
alloc_info.fordblks);
|
||||
printf(" Total space allocated from system = %lu\n",
|
||||
(unsigned long)alloc_info.arena);
|
||||
printf(" Number of non-inuse chunks = %lu\n",
|
||||
(unsigned long)alloc_info.ordblks);
|
||||
printf(" Largest non-inuse chunk = %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
printf(" Total allocated space = %lu\n",
|
||||
(unsigned long)alloc_info.uordblks);
|
||||
printf(" Total non-inuse space = %lu\n",
|
||||
(unsigned long)alloc_info.fordblks);
|
||||
}
|
||||
|
||||
static void do_mallocs(void **mem, const int *size, const int *seq, int n)
|
||||
@ -160,11 +160,13 @@ static void do_mallocs(void **mem, const int *size, const int *seq, int n)
|
||||
fprintf(stderr, "(%d)malloc failed for allocsize=%d\n", i, allocsize);
|
||||
if (allocsize > alloc_info.mxordblk)
|
||||
{
|
||||
fprintf(stderr, " Normal, largest free block is only %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " Normal, largest free block is only %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " ERROR largest free block is %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -199,11 +201,13 @@ static void do_reallocs(void **mem, const int *oldsize, const int *newsize, cons
|
||||
fprintf(stderr, "(%d)realloc failed for allocsize=%d\n", i, allocsize);
|
||||
if (allocsize > alloc_info.mxordblk)
|
||||
{
|
||||
fprintf(stderr, " Normal, largest free block is only %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " Normal, largest free block is only %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " ERROR largest free block is %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -237,11 +241,13 @@ static void do_memaligns(void **mem, const int *size, const int *align, const in
|
||||
fprintf(stderr, "(%d)memalign failed for allocsize=%d\n", i, allocsize);
|
||||
if (allocsize > alloc_info.mxordblk)
|
||||
{
|
||||
fprintf(stderr, " Normal, largest free block is only %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " Normal, largest free block is only %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk);
|
||||
fprintf(stderr, " ERROR largest free block is %lu\n",
|
||||
(unsigned long)alloc_info.mxordblk);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
printf("ERROR: Failed to open file for writing: %d\n", errno);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
}
|
||||
nxffs_freefile(file);
|
||||
return ERROR;
|
||||
@ -361,7 +361,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
printf("ERROR: Failed to write file: %d\n", err);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" Write offset: %ld\n", (long)offset);
|
||||
printf(" Write size: %ld\n", (long)nbytestowrite);
|
||||
ret = ERROR;
|
||||
@ -390,7 +390,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
printf("ERROR: Partial write:\n");
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" Write offset: %ld\n", (long)offset);
|
||||
printf(" Write size: %ld\n", (long)nbytestowrite);
|
||||
printf(" Written: %ld\n", (long)nbyteswritten);
|
||||
@ -459,7 +459,7 @@ static ssize_t nxffs_rdblock(int fd, FAR struct nxffs_filedesc_s *file,
|
||||
{
|
||||
printf("ERROR: Failed to read file: %d\n", errno);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" Read offset: %ld\n", (long)offset);
|
||||
printf(" Read size: %ld\n", (long)len);
|
||||
return ERROR;
|
||||
@ -479,7 +479,7 @@ static ssize_t nxffs_rdblock(int fd, FAR struct nxffs_filedesc_s *file,
|
||||
{
|
||||
printf("ERROR: Partial read:\n");
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" Read offset: %ld\n", (long)offset);
|
||||
printf(" Read size: %ld\n", (long)len);
|
||||
printf(" Bytes read: %ld\n", (long)nbytesread);
|
||||
@ -507,7 +507,7 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
printf("ERROR: Failed to open file for reading: %d\n", errno);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
@ -531,9 +531,10 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file)
|
||||
crc = crc32(g_fileimage, file->len);
|
||||
if (crc != file->crc)
|
||||
{
|
||||
printf("ERROR: Bad CRC: %d vs %d\n", crc, file->crc);
|
||||
printf("ERROR: Bad CRC: %u vs %u\n",
|
||||
(unsigned int)crc, (unsigned int)file->crc);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
close(fd);
|
||||
return ERROR;
|
||||
}
|
||||
@ -545,8 +546,8 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
printf("ERROR: Read past the end of file\n");
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" Bytes read: %d\n", nbytesread);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" Bytes read: %ld\n", (long)nbytesread);
|
||||
close(fd);
|
||||
return ERROR;
|
||||
}
|
||||
@ -588,7 +589,7 @@ static int nxffs_verifyfs(void)
|
||||
{
|
||||
printf("ERROR: Failed to read a file: %d\n", i);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
@ -663,7 +664,7 @@ static int nxffs_delfiles(void)
|
||||
{
|
||||
printf("ERROR: Unlink %d failed: %d\n", i+1, errno);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" File index: %d\n", j);
|
||||
}
|
||||
else
|
||||
@ -710,7 +711,7 @@ static int nxffs_delallfiles(void)
|
||||
{
|
||||
printf("ERROR: Unlink %d failed: %d\n", i+1, errno);
|
||||
printf(" File name: %s\n", file->name);
|
||||
printf(" File size: %d\n", file->len);
|
||||
printf(" File size: %lu\n", (unsigned long)file->len);
|
||||
printf(" File index: %d\n", i);
|
||||
}
|
||||
else
|
||||
|
@ -76,29 +76,29 @@ void thread_func(void *parameter)
|
||||
for (i = 0; i < 20 && !bendoftest; i++);
|
||||
{
|
||||
if ((pthread_mutex_lock(&mut)) != 0)
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_lock failed\n", my_id);
|
||||
}
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_lock failed\n", my_id);
|
||||
}
|
||||
|
||||
if (my_mutex == 1)
|
||||
{
|
||||
printf("ERROR thread=%d: "
|
||||
"my_mutex should be zero, instead my_mutex=%d\n",
|
||||
my_id, my_mutex);
|
||||
nerrors[my_ndx]++;
|
||||
}
|
||||
{
|
||||
printf("ERROR thread=%d: "
|
||||
"my_mutex should be zero, instead my_mutex=%d\n",
|
||||
my_id, my_mutex);
|
||||
nerrors[my_ndx]++;
|
||||
}
|
||||
|
||||
my_mutex = 1;
|
||||
usleep(100000);
|
||||
my_mutex = 0;
|
||||
|
||||
|
||||
if ((pthread_mutex_unlock(&mut)) != 0)
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_unlock failed\n", my_id);
|
||||
}
|
||||
{
|
||||
printf("ERROR thread %d: pthread_mutex_unlock failed\n", my_id);
|
||||
}
|
||||
|
||||
nloops[my_ndx]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -141,9 +141,8 @@ int main(int argc, char **argv)
|
||||
pthread_join(thread2, NULL);
|
||||
|
||||
printf("\tThread1\tThread2\n");
|
||||
printf("Loops\t%ld\t%ld\n", nloops[0], nloops[1]);
|
||||
printf("Errors\t%ld\t%ld\n", nerrors[0], nerrors[1]);
|
||||
printf("Loops\t%lu\t%lu\n", nloops[0], nloops[1]);
|
||||
printf("Errors\t%lu\t%lu\n", nerrors[0], nerrors[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ int nximage_main(int argc, char *argv[])
|
||||
/* Set the background to the configured background color */
|
||||
|
||||
color = nximage_bgcolor();
|
||||
printf("nximage_main: Set background color=%d\n", color);
|
||||
printf("nximage_main: Set background color=%u\n", color);
|
||||
|
||||
ret = nx_setbgcolor(g_nximage.hnx, &color);
|
||||
if (ret < 0)
|
||||
|
@ -180,7 +180,9 @@ static inline void nxpu_fillwindow(NXWINDOW hwnd,
|
||||
FAR struct nxtext_state_s *st)
|
||||
{
|
||||
int ret;
|
||||
#ifdef CONFIG_NX_KBD
|
||||
int i;
|
||||
#endif
|
||||
|
||||
ret = nx_fill(hwnd, rect, st->wcolor);
|
||||
if (ret < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user