Fixes for more cppcheck complaints.

This commit is contained in:
Gregory Nutt 2014-11-25 15:41:34 -06:00
parent 55bfbed33f
commit ecc8c70f77
8 changed files with 25 additions and 28 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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)
{

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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
}

View File

@ -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);
}

View File

@ -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);