From 2349d0806e90cdb8cd77bed4a2a02dba44fa96c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Sun, 16 Feb 2014 20:50:48 +0100 Subject: [PATCH] "Exterminate `} else {`" --- boards/msba2-common/tools/src/download.c | 3 ++- boards/wsn430-common/board_init.c | 3 ++- boards/wsn430-v1_3b/driver_cc110x.c | 3 ++- boards/wsn430-v1_4/driver_cc2420.c | 3 ++- cpu/mc1322x/maca/maca.c | 3 ++- cpu/msp430x16x/hwtimer_msp430.c | 12 ++++-------- cpu/native/syscalls.c | 3 ++- drivers/cc2420/cc2420_rx.c | 25 ++++++++++++------------ drivers/cc2420/cc2420_tx.c | 6 ++++-- sys/net/ccn_lite/ccn-lite-relay.c | 3 ++- sys/net/ccn_lite/ccnl-core.c | 20 ++++++++++++------- sys/net/ccn_lite/ccnl-ext-mgmt.c | 12 ++++++++---- sys/semaphore/semaphore.c | 6 ++++-- sys/shell/commands/sc_mersenne.c | 3 ++- sys/vtimer/vtimer.c | 3 ++- 15 files changed, 64 insertions(+), 44 deletions(-) diff --git a/boards/msba2-common/tools/src/download.c b/boards/msba2-common/tools/src/download.c index 418a062131..f623e814b1 100644 --- a/boards/msba2-common/tools/src/download.c +++ b/boards/msba2-common/tools/src/download.c @@ -837,7 +837,8 @@ static void download_main(int event) // if (chip->bootprog) { // state = BOOT_SOFT; // break; - // } else { + // } + // else { printf("Booting (hardware reset)...\r\n\r\n"); hard_reset_to_user_code(); done_program(0); diff --git a/boards/wsn430-common/board_init.c b/boards/wsn430-common/board_init.c index deb35e4e8e..7177809d7e 100644 --- a/boards/wsn430-common/board_init.c +++ b/boards/wsn430-common/board_init.c @@ -35,7 +35,8 @@ static uint8_t calc_umctl(uint16_t br) { if( a & 0x80 ) { // Overflow to integer? a = a - 128 + CMOD; // Yes, subtract 1.000000 c |= 0x80; - } else { + } + else { a += CMOD; // No, add fraction } if( i == 7 ) { diff --git a/boards/wsn430-v1_3b/driver_cc110x.c b/boards/wsn430-v1_3b/driver_cc110x.c index 8c2a80d509..ad7967b5e7 100644 --- a/boards/wsn430-v1_3b/driver_cc110x.c +++ b/boards/wsn430-v1_3b/driver_cc110x.c @@ -198,7 +198,8 @@ interrupt (PORT1_VECTOR) __attribute__ ((naked)) cc110x_isr(void){ cc110x_gdo0_irq(); P1IE &= ~0x08; // Disable interrupt for GDO0 P1IFG &= ~0x08; // Clear IFG for GDO0 - } else { + } + else { puts("cc110x_isr(): unexpected IFG!"); /* Should not occur - only GDO1 and GDO2 interrupts are enabled */ } diff --git a/boards/wsn430-v1_4/driver_cc2420.c b/boards/wsn430-v1_4/driver_cc2420.c index b8fbfef1ae..2203551eb7 100644 --- a/boards/wsn430-v1_4/driver_cc2420.c +++ b/boards/wsn430-v1_4/driver_cc2420.c @@ -199,7 +199,8 @@ interrupt (PORT1_VECTOR) __attribute__ ((naked)) cc2420_isr(void){ puts("[CC2420] rxfifo overflow"); //P1IE &= ~CC2420_GDO0_PIN; // Disable interrupt for GDO0 P1IFG &= ~CC2420_GDO0_PIN; // Clear IFG for GDO0 - } else if ((P1IFG & CC2420_SFD_PIN) != 0) { + } + else if ((P1IFG & CC2420_SFD_PIN) != 0) { puts("sfd interrupt"); P1IFG &= ~CC2420_SFD_PIN; cc2420_switch_to_rx(); diff --git a/cpu/mc1322x/maca/maca.c b/cpu/mc1322x/maca/maca.c index cb510b9397..28b619813b 100644 --- a/cpu/mc1322x/maca/maca.c +++ b/cpu/mc1322x/maca/maca.c @@ -819,7 +819,8 @@ const uint32_t AIMVAL[19] = { // uint32_t val = *(uint32_t*)(MRRF_BASE); // if ( demod == MACA_DEMOD_NCD ) { // val = (val & ~1); -// } else { +// } +// else { // val = (val | 1); // } // *(uint32_t*)(MRRF_BASE) = val; diff --git a/cpu/msp430x16x/hwtimer_msp430.c b/cpu/msp430x16x/hwtimer_msp430.c index e93cbe6b86..4173cf8b3a 100644 --- a/cpu/msp430x16x/hwtimer_msp430.c +++ b/cpu/msp430x16x/hwtimer_msp430.c @@ -57,7 +57,6 @@ interrupt(TIMERA0_VECTOR) __attribute__((naked)) timer_isr_ccr0(void) __enter_isr(); timer_round += 1; __exit_isr(); - } interrupt(TIMERA1_VECTOR) __attribute__((naked)) timer_isr(void) @@ -65,16 +64,13 @@ interrupt(TIMERA1_VECTOR) __attribute__((naked)) timer_isr(void) __enter_isr(); short taiv = TAIV; - - if (taiv & TAIV_TAIFG) { - } else { - - short timer = (taiv/2); - if(overflow_interrupt[timer] == timer_round) - { + if (!(taiv & TAIV_TAIFG)) { + short timer = taiv / 2; + if (overflow_interrupt[timer] == timer_round) { timer_unset(timer); int_handler(timer); } } + __exit_isr(); } diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 2a8995598a..bdc06e8b31 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -176,7 +176,8 @@ char *make_message(const char *format, va_list argp) if ((temp = realloc(message, size)) == NULL) { free(message); return NULL; - } else { + } + else { message = temp; } } diff --git a/drivers/cc2420/cc2420_rx.c b/drivers/cc2420/cc2420_rx.c index cb5391b78b..76c0dab9bd 100644 --- a/drivers/cc2420/cc2420_rx.c +++ b/drivers/cc2420/cc2420_rx.c @@ -50,21 +50,22 @@ void cc2420_rx_handler(void) cc2420_rx_buffer[rx_buffer_next].length-2); if(cc2420_rx_buffer[rx_buffer_next].frame.fcf.frame_type != 2) { #ifdef DEBUG - ieee802154_frame_print_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame); -#endif - /* notify transceiver thread if any */ - if (transceiver_pid) { - msg_t m; - m.type = (uint16_t) RCV_PKT_CC2420; - m.content.value = rx_buffer_next; - msg_send_int(&m, transceiver_pid); - } - } else { -#ifdef DEBUG - DEBUG("GOT ACK for SEQ %u\n", cc2420_rx_buffer[rx_buffer_next].frame.seq_nr); ieee802154_frame_print_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame); #endif + /* notify transceiver thread if any */ + if (transceiver_pid) { + msg_t m; + m.type = (uint16_t) RCV_PKT_CC2420; + m.content.value = rx_buffer_next; + msg_send_int(&m, transceiver_pid); + } } +#ifdef DEBUG + else { + DEBUG("GOT ACK for SEQ %u\n", cc2420_rx_buffer[rx_buffer_next].frame.seq_nr); + ieee802154_frame_print_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame); + } +#endif /* shift to next buffer element */ if (++rx_buffer_next == CC2420_RX_BUF_SIZE) { diff --git a/drivers/cc2420/cc2420_tx.c b/drivers/cc2420/cc2420_tx.c index 56130e9a26..2ab3a714cc 100644 --- a/drivers/cc2420/cc2420_tx.c +++ b/drivers/cc2420/cc2420_tx.c @@ -31,14 +31,16 @@ int16_t cc2420_send(cc2420_packet_t *packet) packet->frame.fcf.frame_ver = 0; if(packet->frame.src_pan_id == packet->frame.dest_pan_id) { packet->frame.fcf.panid_comp = 1; - } else { + } + else { packet->frame.fcf.panid_comp = 0; } if(packet->frame.fcf.src_addr_m == 2) { packet->frame.src_addr[1] = (uint8_t)(cc2420_get_address() >> 8); packet->frame.src_addr[0] = (uint8_t)(cc2420_get_address() & 0xFF); - } else if (packet->frame.fcf.src_addr_m == 3) { + } + else if (packet->frame.fcf.src_addr_m == 3) { packet->frame.src_addr[7] = (uint8_t)(cc2420_get_address_long() >> 56); packet->frame.src_addr[6] = (uint8_t)(cc2420_get_address_long() >> 48); packet->frame.src_addr[5] = (uint8_t)(cc2420_get_address_long() >> 40); diff --git a/sys/net/ccn_lite/ccn-lite-relay.c b/sys/net/ccn_lite/ccn-lite-relay.c index cce0259f11..834e820d17 100644 --- a/sys/net/ccn_lite/ccn-lite-relay.c +++ b/sys/net/ccn_lite/ccn-lite-relay.c @@ -333,7 +333,8 @@ int ccnl_io_loop(struct ccnl_relay_s *ccnl) hwtimer_id = hwtimer_set(HWTIMER_TICKS(us), ccnl_timeout_callback, ccnl); if (hwtimer_id == -1) { puts("NO MORE TIMERS!"); - } else { + } + else { //DEBUGMSG(1, "hwtimer_id is %d\n", hwtimer_id); } msg_receive(&in); diff --git a/sys/net/ccn_lite/ccnl-core.c b/sys/net/ccn_lite/ccnl-core.c index d67359d4cd..deb28b523f 100644 --- a/sys/net/ccn_lite/ccnl-core.c +++ b/sys/net/ccn_lite/ccnl-core.c @@ -947,7 +947,8 @@ ccnl_content_add2cache(struct ccnl_relay_s *ccnl, struct ccnl_content_s *c) if (oldest) { DEBUGMSG(1, " replaced: '%s'\n", ccnl_prefix_to_path(oldest->name)); ccnl_content_remove(ccnl, oldest); - } else { + } + else { DEBUGMSG(1, " no dynamic content to remove...\n"); break; } @@ -1062,7 +1063,8 @@ void ccnl_content_learn_name_route(struct ccnl_relay_s *ccnl, struct ccnl_prefix fwd = ccnl_forward_new(p, f, threshold_prefix, flags); DBL_LINKED_LIST_ADD(ccnl->fib, fwd); DEBUGMSG(999, "ccnl_content_learn_name_route: new route '%s' on face %d learned\n", ccnl_prefix_to_path(fwd->prefix), f->faceid); - } else { + } + else { /* there was a prefix match with the user defined creteria. */ /* if the new entry has shorter prefix */ @@ -1074,7 +1076,8 @@ void ccnl_content_learn_name_route(struct ccnl_relay_s *ccnl, struct ccnl_prefix fwd = ccnl_forward_new(p, f, (p->compcnt - match_len), flags); DBL_LINKED_LIST_ADD(ccnl->fib, fwd); DEBUGMSG(999, "ccnl_content_learn_name_route: route '%s' on face %d replaced\n", ccnl_prefix_to_path(fwd->prefix), f->faceid); - } else { + } + else { /* we don't need to do an update, because we know a shorter prefix already */ } } @@ -1161,7 +1164,8 @@ void ccnl_do_ageing(void *ptr, void *dummy) riot_send_nack(i->from->faceid); } i = ccnl_interest_remove(relay, i); - } else { + } + else { i = i->next; } } @@ -1191,7 +1195,8 @@ void ccnl_do_ageing(void *ptr, void *dummy) if (!(fwd->flags & CCNL_FORWARD_FLAGS_STATIC) && ccnl_is_timeouted(&now, &fwd->last_used, CCNL_FWD_TIMEOUT_SEC, CCNL_FWD_TIMEOUT_USEC)) { fwd = ccnl_forward_remove(relay, fwd); - } else { + } + else { fwd = fwd->next; } } @@ -1340,12 +1345,13 @@ int ccnl_core_RX_i_or_c(struct ccnl_relay_s *relay, struct ccnl_face_s *from, DEBUGMSG(7, " removed because no matching interest\n"); free_content(c); goto Skip; - } else { + } #if CCNL_DYNAMIC_FIB + else { /* content has matched an interest, we consider this name as available on this face */ ccnl_content_learn_name_route(relay, c->name, from, relay->fib_threshold_prefix, 0); -#endif } +#endif if (relay->max_cache_entries != 0) { // it's set to -1 or a limit DEBUGMSG(7, " adding content to cache\n"); diff --git a/sys/net/ccn_lite/ccnl-ext-mgmt.c b/sys/net/ccn_lite/ccnl-ext-mgmt.c index 24dc69d012..4f24a0ad57 100644 --- a/sys/net/ccn_lite/ccnl-ext-mgmt.c +++ b/sys/net/ccn_lite/ccnl-ext-mgmt.c @@ -551,10 +551,12 @@ static int ccnl_mgmt_handle(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig, if (!strcmp(cmd, "newface")) { DEBUGMSG(1, "ccnl_mgmt_newface msg\n"); ccnl_mgmt_newface(ccnl, orig, prefix, from); - } else if (!strcmp(cmd, "prefixreg")) { + } + else if (!strcmp(cmd, "prefixreg")) { DEBUGMSG(1, "ccnl_mgmt_prefixreg msg\n"); ccnl_mgmt_prefixreg(ccnl, orig, prefix, from); - } else { + } + else { DEBUGMSG(99, "unknown mgmt command %s\n", cmd); ccnl_mgmt_return_msg(ccnl, orig, from, "unknown mgmt command"); @@ -571,14 +573,16 @@ int ccnl_mgmt(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig, if (prefix->complen[2] < (int) sizeof(cmd)) { memcpy(cmd, prefix->comp[2], prefix->complen[2]); cmd[prefix->complen[2]] = '\0'; - } else { + } + else { strcpy(cmd, "cmd-is-too-long-to-display"); } DEBUGMSG(99, "ccnl_mgmt request \"%s\"\n", cmd); - if (ccnl_is_local_addr(from)) + if (ccnl_is_local_addr(from)) { goto MGMT; + } DEBUGMSG(99, " rejecting because src is not a local addr\n"); ccnl_mgmt_return_msg(ccnl, orig, from, diff --git a/sys/semaphore/semaphore.c b/sys/semaphore/semaphore.c index 9555a89b06..7fd91df7e8 100644 --- a/sys/semaphore/semaphore.c +++ b/sys/semaphore/semaphore.c @@ -100,7 +100,8 @@ int sem_wait(sem_t *sem) if (value == 0) { sem_thread_blocked(sem); continue; - } else { + } + else { sem->value = value - 1; break; } @@ -124,7 +125,8 @@ int sem_trywait(sem_t *sem) unsigned value = sem->value; if (value == 0) { result = -1; - } else { + } + else { result = 0; sem->value = value - 1; } diff --git a/sys/shell/commands/sc_mersenne.c b/sys/shell/commands/sc_mersenne.c index 8cfdcc91fd..b6440e9b3f 100644 --- a/sys/shell/commands/sc_mersenne.c +++ b/sys/shell/commands/sc_mersenne.c @@ -32,7 +32,8 @@ void _mersenne_init(char *str) if (!toc_str) { initval = hwtimer_now(); printf("PRNG inizialized to current time: %d\n", initval); - } else { + } + else { initval = atoi(toc_str); printf("PRNG inizialized given value: %d\n", initval); } diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c index ea1c368b6e..fbadbb50da 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -370,7 +370,8 @@ int vtimer_msg_receive_timeout(msg_t *m, timex_t timeout) { if (m->type == MSG_TIMER && m->content.ptr == (char *) &timeout_message) { /* we hit the timeout */ return -1; - } else { + } + else { vtimer_remove(&t); return 1; }