From 6363fad05b2d312482bde3b54e43e8b0e9831532 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 25 Nov 2014 15:41:34 -0600 Subject: Fixes for more cppcheck complaints. --- apps/system/hex2bin/hex2bin_main.c | 3 +-- apps/system/hex2bin/hex2mem_main.c | 3 +-- apps/system/install/install.c | 4 ++-- apps/system/mdio/mdio_main.c | 3 +-- apps/system/nxplayer/nxplayer.c | 32 ++++++++++++++++---------------- apps/system/stackmonitor/stackmonitor.c | 2 +- apps/system/vi/vi.c | 4 ++-- apps/system/zmodem/zm_receive.c | 2 +- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/apps/system/hex2bin/hex2bin_main.c b/apps/system/hex2bin/hex2bin_main.c index f3acc44cd..6610491e4 100644 --- a/apps/system/hex2bin/hex2bin_main.c +++ b/apps/system/hex2bin/hex2bin_main.c @@ -257,8 +257,7 @@ int hex2bin_main(int argc, char **argv) (enum hex2bin_swap_e)swap); if (ret < 0) { - fprintf(stderr, "ERROR: Failed to convert \"%s\" to binary: %d\n", - ret); + fprintf(stderr, "ERROR: Failed to convert to binary: %d\n", ret); } /* Clean up and return */ diff --git a/apps/system/hex2bin/hex2mem_main.c b/apps/system/hex2bin/hex2mem_main.c index 03feb1ea9..8f82f273b 100644 --- a/apps/system/hex2bin/hex2mem_main.c +++ b/apps/system/hex2bin/hex2mem_main.c @@ -238,8 +238,7 @@ int hex2mem_main(int argc, char **argv) (enum hex2bin_swap_e)swap); if (ret < 0) { - fprintf(stderr, "ERROR: Failed to convert \"%s\" to binary: %d\n", - ret); + fprintf(stderr, "ERROR: Failed to convert to binary: %d\n", ret); } /* Clean up and return */ diff --git a/apps/system/install/install.c b/apps/system/install/install.c index f204ff944..cf54bd4bb 100644 --- a/apps/system/install/install.c +++ b/apps/system/install/install.c @@ -357,9 +357,9 @@ int install_main(int argc, char *argv[]) /* Parse arguments */ - for (i=1; isem) != OK) + while (sem_wait(&pPlayer->sem) < 0) ; #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS @@ -1076,7 +1076,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume) /* Thread sync using the semaphore */ - while (sem_wait(&pPlayer->sem) != OK) + while (sem_wait(&pPlayer->sem) < 0) ; /* If we are currently playing, then we need to post a message to @@ -1162,7 +1162,7 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t level) /* Thread sync using the semaphore */ - while (sem_wait(&pPlayer->sem) != OK) + while (sem_wait(&pPlayer->sem) < 0) ; /* If we are currently playing, then we need to post a message to @@ -1214,7 +1214,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t level) /* Thread sync using the semaphore */ - while (sem_wait(&pPlayer->sem) != OK) + while (sem_wait(&pPlayer->sem) < 0) ; /* If we are currently playing, then we need to post a message to @@ -1261,7 +1261,7 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance) /* Thread sync using the semaphore */ - while (sem_wait(&pPlayer->sem) != OK) + while (sem_wait(&pPlayer->sem) < 0) ; /* If we are currently playing, then we need to post a message to @@ -1767,7 +1767,9 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, attr.mq_curmsgs = 0; attr.mq_flags = 0; - snprintf(pPlayer->mqname, sizeof(pPlayer->mqname), "/tmp/%0X", pPlayer); + snprintf(pPlayer->mqname, sizeof(pPlayer->mqname), "/tmp/%0lx", + (unsigned long)((uintptr_t)pPlayer)); + pPlayer->mq = mq_open(pPlayer->mqname, O_RDWR | O_CREAT, 0644, &attr); if (pPlayer->mq == NULL) { @@ -1929,12 +1931,12 @@ FAR struct nxplayer_s *nxplayer_create(void) void nxplayer_release(FAR struct nxplayer_s* pPlayer) { - int refcount, ret; + int refcount; FAR void* value; /* Grab the semaphore */ - while ((ret = sem_wait(&pPlayer->sem)) != OK) + while (sem_wait(&pPlayer->sem) < 0) { int errcode = errno; DEBUGASSERT(errcode > 0); @@ -1954,7 +1956,7 @@ void nxplayer_release(FAR struct nxplayer_s* pPlayer) pthread_join(pPlayer->playId, &value); pPlayer->playId = 0; - while ((ret = sem_wait(&pPlayer->sem)) != OK) + while (sem_wait(&pPlayer->sem) < 0) { int errcode = errno; DEBUGASSERT(errcode > 0); @@ -1975,7 +1977,9 @@ void nxplayer_release(FAR struct nxplayer_s* pPlayer) /* If the ref count *was* one, then free the context */ if (refcount == 1) - free(pPlayer); + { + free(pPlayer); + } } /**************************************************************************** @@ -1992,11 +1996,9 @@ void nxplayer_release(FAR struct nxplayer_s* pPlayer) void nxplayer_reference(FAR struct nxplayer_s* pPlayer) { - int ret; - /* Grab the semaphore */ - while ((ret = sem_wait(&pPlayer->sem)) != OK) + while (sem_wait(&pPlayer->sem) < 0) { int errcode = errno; DEBUGASSERT(errcode > 0); @@ -2031,11 +2033,9 @@ void nxplayer_reference(FAR struct nxplayer_s* pPlayer) void nxplayer_detach(FAR struct nxplayer_s* pPlayer) { #if 0 - int ret; - /* Grab the semaphore */ - while ((ret = sem_wait(&pPlayer->sem)) != OK) + while (sem_wait(&pPlayer->sem) < 0) { int errcode = errno; DEBUGASSERT(errcode > 0); diff --git a/apps/system/stackmonitor/stackmonitor.c b/apps/system/stackmonitor/stackmonitor.c index f152d36fa..fcf0dff38 100644 --- a/apps/system/stackmonitor/stackmonitor.c +++ b/apps/system/stackmonitor/stackmonitor.c @@ -101,7 +101,7 @@ static void stkmon_task(FAR struct tcb_s *tcb, FAR void *arg) syslog(LOG_INFO, "%5d %6d %6d %s\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name); #else - syslog(LOG_INFO, ("%5d %6d %6d\n", + syslog(LOG_INFO, "%5d %6d %6d\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb)); #endif } diff --git a/apps/system/vi/vi.c b/apps/system/vi/vi.c index 6c145a23d..c2524f887 100644 --- a/apps/system/vi/vi.c +++ b/apps/system/vi/vi.c @@ -3636,7 +3636,7 @@ int vi_main(int argc, char **argv) } else { - fprintf(stderr, "ERROR: Column value out of range: %ld\n", + fprintf(stderr, "ERROR: Column value out of range: %lu\n", value); vi_showusage(vi, argv[0], EXIT_FAILURE); } @@ -3652,7 +3652,7 @@ int vi_main(int argc, char **argv) } else { - fprintf(stderr, "ERROR: Row value out of range: %ld\n", + fprintf(stderr, "ERROR: Row value out of range: %lu\n", value); vi_showusage(vi, argv[0], EXIT_FAILURE); } diff --git a/apps/system/zmodem/zm_receive.c b/apps/system/zmodem/zm_receive.c index e04a7ee11..60378d456 100644 --- a/apps/system/zmodem/zm_receive.c +++ b/apps/system/zmodem/zm_receive.c @@ -670,7 +670,7 @@ static int zmr_filename(FAR struct zm_state_s *pzm) bremaining = 0; filetype = 0; - sscanf((FAR char *)pktptr, "%ld %lo %o %o %d %ld %d", + sscanf((FAR char *)pktptr, "%lu %lo %o %o %d %lu %d", &filesize, ×tamp, &mode, &serialno, &fremaining, &bremaining, &filetype); -- cgit v1.2.3