From a8e83d8923e2c82ac8448d90191e7698cd0c4b81 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 27 Oct 2014 10:34:19 +0100 Subject: [PATCH] rpl_udp: optimize error handling for set command --- examples/rpl_udp/helper.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/rpl_udp/helper.c b/examples/rpl_udp/helper.c index 2b2b567c5f..a0cf2eaf04 100644 --- a/examples/rpl_udp/helper.c +++ b/examples/rpl_udp/helper.c @@ -127,11 +127,20 @@ void rpl_udp_ignore(int argc, char **argv) { uint16_t a; + if (argc < 2) { + printf("Usage: %s \n", argv[0]); + return; + } + if (transceiver_pid == KERNEL_PID_UNDEF) { puts("Transceiver not runnning."); return; } + /* cppcheck: a is actually read via tcmd.data */ + /* cppcheck-suppress unreadVariable */ + a = atoi(argv[1]); + msg_t mesg; mesg.type = DBG_IGN; mesg.content.ptr = (char *) &tcmd; @@ -139,14 +148,7 @@ void rpl_udp_ignore(int argc, char **argv) tcmd.transceivers = TRANSCEIVER_CC1100; tcmd.data = &a; - if (argc == 2) { - /* cppcheck: a is actually read via tcmd.data */ - /* cppcheck-suppress unreadVariable */ - a = atoi(argv[1]); - printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data)); - msg_send(&mesg, transceiver_pid); - } - else { - printf("Usage: %s \n", argv[0]); - } + printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, + (*(uint8_t *)tcmd.data)); + msg_send(&mesg, transceiver_pid); }