summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-25 11:45:00 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-25 11:45:00 -0600
commitc9b18b049b09580260188349bb32e91b59f74965 (patch)
tree14929ed18bf0cfc14d32d78825b3f3a47ae7d589
parentb756c4b51f51427339bf3649430f8470f64d7a8d (diff)
downloadnuttx-c9b18b049b09580260188349bb32e91b59f74965.tar.gz
nuttx-c9b18b049b09580260188349bb32e91b59f74965.tar.bz2
nuttx-c9b18b049b09580260188349bb32e91b59f74965.zip
More fixes to issues noted by cppcheck
-rw-r--r--apps/examples/cc3000/cc3000basic.c2
-rw-r--r--apps/examples/ostest/mqueue.c2
-rw-r--r--apps/examples/ostest/mutex.c4
-rw-r--r--apps/examples/ostest/sighand.c12
-rw-r--r--apps/examples/ostest/timedmqueue.c4
-rw-r--r--apps/examples/pashello/pashello.c1
-rw-r--r--apps/examples/pipe/interlock_test.c4
-rw-r--r--apps/examples/pwm/pwm_main.c8
-rw-r--r--apps/examples/qencoder/qe_main.c2
-rw-r--r--apps/examples/relays/relays_main.c1
10 files changed, 15 insertions, 25 deletions
diff --git a/apps/examples/cc3000/cc3000basic.c b/apps/examples/cc3000/cc3000basic.c
index ae786c4e7..544e565b9 100644
--- a/apps/examples/cc3000/cc3000basic.c
+++ b/apps/examples/cc3000/cc3000basic.c
@@ -305,7 +305,7 @@ void AsyncEventPrint(void)
break;
default:
- printf("AsyncCallback called with unhandled event! (0x%lx)\n", \
+ printf("AsyncCallback called with unhandled event! (0x%lx)\n",
(unsigned long)lastAsyncEvent);
break;
}
diff --git a/apps/examples/ostest/mqueue.c b/apps/examples/ostest/mqueue.c
index b5f1ffb56..4f1c48807 100644
--- a/apps/examples/ostest/mqueue.c
+++ b/apps/examples/ostest/mqueue.c
@@ -403,7 +403,7 @@ void mqueue_test(void)
pthread_join(receiver, &result);
if (result != expected)
{
- printf("mqueue_test: ERROR receiver thread should have exited with %d\n",
+ printf("mqueue_test: ERROR receiver thread should have exited with %p\n",
expected);
printf(" ERROR Instead exited with nerrors=%d\n",
(int)result);
diff --git a/apps/examples/ostest/mutex.c b/apps/examples/ostest/mutex.c
index 0b7f70daa..1951a4039 100644
--- a/apps/examples/ostest/mutex.c
+++ b/apps/examples/ostest/mutex.c
@@ -137,6 +137,6 @@ void mutex_test(void)
#endif
printf("\t\tThread1\tThread2\n");
- printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]);
- printf("\tErrors\t%ld\t%ld\n", nerrors[0], nerrors[1]);
+ printf("\tLoops\t%lu\t%lu\n", nloops[0], nloops[1]);
+ printf("\tErrors\t%lu\t%lu\n", nerrors[0], nerrors[1]);
}
diff --git a/apps/examples/ostest/sighand.c b/apps/examples/ostest/sighand.c
index ab1c15c0e..4f42dcff1 100644
--- a/apps/examples/ostest/sighand.c
+++ b/apps/examples/ostest/sighand.c
@@ -204,7 +204,7 @@ static int waiter_main(int argc, char *argv[])
/* Detach the signal handler */
act.sa_sigaction = SIG_DFL;
- status = sigaction(WAKEUP_SIGNAL, &act, &oact);
+ (void)sigaction(WAKEUP_SIGNAL, &act, &oact);
printf("waiter_main: done\n" );
FFLUSH();
@@ -223,7 +223,6 @@ void sighand_test(void)
struct sched_param param;
union sigval sigvalue;
pid_t waiterpid;
- int policy;
int status;
printf("sighand_test: Initializing semaphore to 0\n" );
@@ -265,13 +264,6 @@ void sighand_test(void)
param.sched_priority = PTHREAD_DEFAULT_PRIORITY;
}
- policy = sched_getscheduler(0);
- if (policy == ERROR)
- {
- printf("sighand_test: ERROR sched_getscheduler() failed\n" );
- policy = SCHED_FIFO;
- }
-
waiterpid = task_create("waiter", param.sched_priority,
PTHREAD_STACK_DEFAULT, waiter_main, NULL);
if (waiterpid == ERROR)
@@ -326,7 +318,7 @@ void sighand_test(void)
#ifdef CONFIG_SCHED_HAVE_PARENT
act.sa_sigaction = SIG_DFL;
- status = sigaction(SIGCHLD, &act, &oact);
+ (void)sigaction(SIGCHLD, &act, &oact);
#endif
printf("sighand_test: done\n" );
diff --git a/apps/examples/ostest/timedmqueue.c b/apps/examples/ostest/timedmqueue.c
index 24dd0bc34..5792b426e 100644
--- a/apps/examples/ostest/timedmqueue.c
+++ b/apps/examples/ostest/timedmqueue.c
@@ -124,7 +124,7 @@ static void *sender_thread(void *arg)
*/
g_send_mqfd = mq_open("timedmq", O_WRONLY|O_CREAT, 0666, &attr);
- if (g_send_mqfd < 0)
+ if (g_send_mqfd == (mqd_t)-1)
{
printf("sender_thread: ERROR mq_open failed\n");
pthread_exit((pthread_addr_t)1);
@@ -221,7 +221,7 @@ static void *receiver_thread(void *arg)
*/
g_recv_mqfd = mq_open("timedmq", O_RDONLY|O_CREAT, 0666, &attr);
- if (g_recv_mqfd < 0)
+ if (g_recv_mqfd == (mqd_t)-1)
{
printf("receiver_thread: ERROR mq_open failed\n");
pthread_exit((pthread_addr_t)1);
diff --git a/apps/examples/pashello/pashello.c b/apps/examples/pashello/pashello.c
index f76e530ca..94ddf2e65 100644
--- a/apps/examples/pashello/pashello.c
+++ b/apps/examples/pashello/pashello.c
@@ -81,7 +81,6 @@ int main(int argc, FAR char *argv[])
int pashello_main(int argc, FAR char *argv[])
#endif
{
- FAR struct pexec_s *st;
int exitcode = EXIT_SUCCESS;
int ret;
diff --git a/apps/examples/pipe/interlock_test.c b/apps/examples/pipe/interlock_test.c
index 0391fe36f..d06442950 100644
--- a/apps/examples/pipe/interlock_test.c
+++ b/apps/examples/pipe/interlock_test.c
@@ -172,8 +172,8 @@ int interlock_test(void)
}
else if (ret != 0)
{
- fprintf(stderr, "interlock_test: Read %d bytes of data -- aborting: %d\n",
- nbytes, errno);
+ fprintf(stderr, "interlock_test: Read %ld bytes of data -- aborting: %d\n",
+ (long)nbytes, errno);
ret = 5;
goto errout_with_file;
}
diff --git a/apps/examples/pwm/pwm_main.c b/apps/examples/pwm/pwm_main.c
index e9a6cc50e..ba5687541 100644
--- a/apps/examples/pwm/pwm_main.c
+++ b/apps/examples/pwm/pwm_main.c
@@ -124,14 +124,14 @@ static void pwm_help(FAR struct pwm_state_s *pwm)
"Default: %s Current: %s\n",
CONFIG_EXAMPLES_PWM_DEVPATH, pwm->devpath ? pwm->devpath : "NONE");
printf(" [-f frequency] selects the pulse frequency. "
- "Default: %d Hz Current: %d Hz\n",
+ "Default: %d Hz Current: %u Hz\n",
CONFIG_EXAMPLES_PWM_FREQUENCY, pwm->freq);
printf(" [-d duty] selects the pulse duty as a percentage. "
"Default: %d %% Current: %d %%\n",
CONFIG_EXAMPLES_PWM_DUTYPCT, pwm->duty);
#ifdef CONFIG_PWM_PULSECOUNT
printf(" [-n count] selects the pulse count. "
- "Default: %d Current: %d\n",
+ "Default: %d Current: %u\n",
CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count);
#endif
printf(" [-t duration] is the duration of the pulse train in seconds. "
@@ -336,11 +336,11 @@ int pwm_main(int argc, char *argv[])
#ifdef CONFIG_PWM_PULSECOUNT
info.count = g_pwmstate.count;
- printf("pwm_main: starting output with frequency: %d duty: %08x count: %d\n",
+ printf("pwm_main: starting output with frequency: %u duty: %08x count: %u\n",
info.frequency, info.duty, info.count);
#else
- printf("pwm_main: starting output with frequency: %d duty: %08x\n",
+ printf("pwm_main: starting output with frequency: %u duty: %08x\n",
info.frequency, info.duty);
#endif
diff --git a/apps/examples/qencoder/qe_main.c b/apps/examples/qencoder/qe_main.c
index 5085c7197..2042eaf93 100644
--- a/apps/examples/qencoder/qe_main.c
+++ b/apps/examples/qencoder/qe_main.c
@@ -315,7 +315,7 @@ int qe_main(int argc, char *argv[])
*/
#if defined(CONFIG_NSH_BUILTIN_APPS)
- printf("qe_main: Number of samples: %d\n", g_qeexample.nloops);
+ printf("qe_main: Number of samples: %u\n", g_qeexample.nloops);
for (nloops = 0; nloops < g_qeexample.nloops; nloops++)
#elif defined(CONFIG_EXAMPLES_QENCODER_NSAMPLES)
printf("qe_main: Number of samples: %d\n", CONFIG_EXAMPLES_QENCODER_NSAMPLES);
diff --git a/apps/examples/relays/relays_main.c b/apps/examples/relays/relays_main.c
index 8989da821..92fc02c17 100644
--- a/apps/examples/relays/relays_main.c
+++ b/apps/examples/relays/relays_main.c
@@ -98,7 +98,6 @@ int relays_main(int argc, char *argv[])
uint32_t r_stat;
int option;
int n = -1;
- int ret = -1;
int i;
while ((option = getopt(argc, argv, ":n:")) != ERROR)