summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-25 15:41:34 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-25 15:41:34 -0600
commit6363fad05b2d312482bde3b54e43e8b0e9831532 (patch)
treea89cd2604a1c5b434c64831871c7d1a3da35f5ba
parent76d6af0fd310967d8bf08d01cfc1db00e4a0c757 (diff)
downloadnuttx-6363fad05b2d312482bde3b54e43e8b0e9831532.tar.gz
nuttx-6363fad05b2d312482bde3b54e43e8b0e9831532.tar.bz2
nuttx-6363fad05b2d312482bde3b54e43e8b0e9831532.zip
Fixes for more cppcheck complaints.
-rw-r--r--apps/system/hex2bin/hex2bin_main.c3
-rw-r--r--apps/system/hex2bin/hex2mem_main.c3
-rw-r--r--apps/system/install/install.c4
-rw-r--r--apps/system/mdio/mdio_main.c3
-rw-r--r--apps/system/nxplayer/nxplayer.c32
-rw-r--r--apps/system/stackmonitor/stackmonitor.c2
-rw-r--r--apps/system/vi/vi.c4
-rw-r--r--apps/system/zmodem/zm_receive.c2
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; i<argc; i++)
+ for (i = 1; i < argc; i++)
{
- if (argv[i][0]=='-' && argv[i][1]=='-' && i<=argc)
+ if (i <= argc && argv[i][0]=='-' && argv[i][1]=='-')
{
if (strcmp(argv[i]+2, "stack")==0)
{
diff --git a/apps/system/mdio/mdio_main.c b/apps/system/mdio/mdio_main.c
index 07dd8752a..2c5976d67 100644
--- a/apps/system/mdio/mdio_main.c
+++ b/apps/system/mdio/mdio_main.c
@@ -222,8 +222,7 @@ int mdio_main(int argc, char *argv[])
for (i = 0; i < 32; i++)
{
- ret = get_phy_reg(phy_id, i, &val_out);
-
+ (void)get_phy_reg(phy_id, i, &val_out);
printf("phy[%d][%d] = 0x%4x\n", phy_id, i, val_out);
}
}
diff --git a/apps/system/nxplayer/nxplayer.c b/apps/system/nxplayer/nxplayer.c
index fbc60b666..597ea0952 100644
--- a/apps/system/nxplayer/nxplayer.c
+++ b/apps/system/nxplayer/nxplayer.c
@@ -993,7 +993,7 @@ err_out:
/* Cleanup */
- while (sem_wait(&pPlayer->sem) != 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, &timestamp, &mode, &serialno, &fremaining, &bremaining,
&filetype);