diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index 9bb906f6d..3a08df83a 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -671,8 +671,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) int ext_hdr_len; struct uip_udp_hdr *udp_buf; -#if LOG_DBG_ENABLED - { uint16_t ndx; + if(LOG_DBG_ENABLED) { + uint16_t ndx; LOG_DBG("before compression (%d): ", UIP_IP_BUF->len[1]); for(ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) { uint8_t data = ((uint8_t *) (UIP_IP_BUF))[ndx]; @@ -680,7 +680,6 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) } LOG_DBG("\n"); } -#endif /* LOG_DBG_ENABLED */ hc06_ptr = PACKETBUF_IPHC_BUF + 2; /* @@ -996,16 +995,15 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) PACKETBUF_IPHC_BUF[0] = iphc0; PACKETBUF_IPHC_BUF[1] = iphc1; -#if LOG_DBG_ENABLED - { uint16_t ndx; + if(LOG_DBG_ENABLED) { + uint16_t ndx; LOG_DBG("after compression %d: ", (int)(hc06_ptr - packetbuf_ptr)); for(ndx = 0; ndx < hc06_ptr - packetbuf_ptr; ndx++) { uint8_t data = ((uint8_t *) packetbuf_ptr)[ndx]; LOG_DBG("%02x", data); } LOG_DBG("\n"); - } -#endif + } packetbuf_hdr_len = hc06_ptr - packetbuf_ptr; } @@ -1906,8 +1904,7 @@ input(void) LOG_INFO("input: IP packet ready (length %d)\n", uip_len); -#if LOG_DBG_ENABLED - { + if(LOG_DBG_ENABLED) { uint16_t ndx; LOG_DBG("after decompression %u:", UIP_IP_BUF->len[1]); for (ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) { @@ -1916,7 +1913,6 @@ input(void) } LOG_DBG("\n"); } -#endif /* LOG_DBG_ENABLED */ /* if callback is set then set attributes and call */ if(callback) { diff --git a/os/net/ipv6/uip-ds6-route.c b/os/net/ipv6/uip-ds6-route.c index 9321b632c..a8fdd88fb 100644 --- a/os/net/ipv6/uip-ds6-route.c +++ b/os/net/ipv6/uip-ds6-route.c @@ -103,7 +103,6 @@ LIST(notificationlist); #endif /*---------------------------------------------------------------------------*/ -#if LOG_DBG_ENABLED static void assert_nbr_routes_list_sane(void) { @@ -131,7 +130,6 @@ assert_nbr_routes_list_sane(void) } #endif /* (UIP_MAX_ROUTES != 0) */ } -#endif /* LOG_DBG_ENABLED */ /*---------------------------------------------------------------------------*/ #if UIP_DS6_NOTIFICATIONS static void @@ -330,9 +328,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, uip_ds6_route_t *r; struct uip_ds6_route_neighbor_route *nbrr; -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } if(ipaddr == NULL || nexthop == NULL) { return NULL; @@ -473,9 +471,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_ADD, ipaddr, nexthop); #endif -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } return r; #else /* (UIP_MAX_ROUTES != 0) */ @@ -489,9 +487,11 @@ uip_ds6_route_rm(uip_ds6_route_t *route) { #if (UIP_MAX_ROUTES != 0) struct uip_ds6_route_neighbor_route *neighbor_route; -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } + if(route != NULL && route->neighbor_routes != NULL) { LOG_INFO("Rm: removing route: "); @@ -541,9 +541,9 @@ uip_ds6_route_rm(uip_ds6_route_t *route) #endif } -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } #endif /* (UIP_MAX_ROUTES != 0) */ return; @@ -553,9 +553,10 @@ uip_ds6_route_rm(uip_ds6_route_t *route) static void rm_routelist(struct uip_ds6_route_neighbor_routes *routes) { -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } + if(routes != NULL && routes->route_list != NULL) { struct uip_ds6_route_neighbor_route *r; r = list_head(routes->route_list); @@ -565,9 +566,10 @@ rm_routelist(struct uip_ds6_route_neighbor_routes *routes) } nbr_table_remove(nbr_routes, routes); } -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } } /*---------------------------------------------------------------------------*/ static void @@ -603,9 +605,9 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval) { uip_ds6_defrt_t *d; -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } if(ipaddr == NULL) { return NULL; @@ -643,9 +645,9 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval) call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr); #endif -#if LOG_DBG_ENABLED +if(LOG_DBG_ENABLED) { assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ +} return d; } @@ -655,9 +657,9 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt) { uip_ds6_defrt_t *d; -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } /* Make sure that the defrt is in the list before we remove it. */ for(d = list_head(defaultrouterlist); @@ -675,10 +677,10 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt) return; } } -#if LOG_DBG_ENABLED - assert_nbr_routes_list_sane(); -#endif /* LOG_DBG_ENABLED */ + if(LOG_DBG_ENABLED) { + assert_nbr_routes_list_sane(); + } } /*---------------------------------------------------------------------------*/ uip_ds6_defrt_t * diff --git a/os/net/ipv6/uip-sr.c b/os/net/ipv6/uip-sr.c index 9b859fb3a..15b123552 100644 --- a/os/net/ipv6/uip-sr.c +++ b/os/net/ipv6/uip-sr.c @@ -217,13 +217,13 @@ uip_sr_periodic(unsigned seconds) break; } } -#if LOG_INFO_ENABLED - uip_ipaddr_t node_addr; - NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, l); - LOG_INFO("NS: removing expired node "); - LOG_INFO_6ADDR(&node_addr); - LOG_INFO_("\n"); -#endif /* LOG_INFO_ENABLED */ + if(LOG_INFO_ENABLED) { + uip_ipaddr_t node_addr; + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, l); + LOG_INFO("NS: removing expired node "); + LOG_INFO_6ADDR(&node_addr); + LOG_INFO_("\n"); + } /* No child found, deallocate node */ list_remove(nodelist, l); memb_free(&nodememb, l); diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index fed488013..5074dd482 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -185,9 +185,9 @@ rpl_global_repair(const char *str) if(rpl_dag_root_is_root()) { LOG_WARN("initiating global repair (%s), version %u, rank %u)\n", str, curr_instance.dag.version, curr_instance.dag.rank); -#if LOG_INFO_ENABLED - rpl_neighbor_print_list("Global repair (before)"); -#endif /* LOG_INFO_ENABLED */ + if(LOG_INFO_ENABLED) { + rpl_neighbor_print_list("Global repair (before)"); + } /* Initiate global repair */ RPL_LOLLIPOP_INCREMENT(curr_instance.dag.version); /* New DAG version */ @@ -202,9 +202,9 @@ global_repair_non_root(rpl_dio_t *dio) if(!rpl_dag_root_is_root()) { LOG_WARN("participating in global repair, version %u, rank %u)\n", curr_instance.dag.version, curr_instance.dag.rank); -#if LOG_INFO_ENABLED - rpl_neighbor_print_list("Global repair (before)"); -#endif /* LOG_INFO_ENABLED */ + if(LOG_INFO_ENABLED) { + rpl_neighbor_print_list("Global repair (before)"); + } /* Re-initialize configuration from DIO */ init_dag_from_dio(dio); rpl_local_repair("Global repair"); @@ -325,9 +325,9 @@ rpl_dag_update_state(void) rpl_timers_schedule_leaving(); } -#if LOG_INFO_ENABLED - rpl_neighbor_print_list("Parent switch"); -#endif /* LOG_INFO_ENABLED */ + if(LOG_INFO_ENABLED) { + rpl_neighbor_print_list("Parent switch"); + } } } diff --git a/os/net/routing/rpl-lite/rpl-nbr-policy.c b/os/net/routing/rpl-lite/rpl-nbr-policy.c index f848ddb39..3db84f3a8 100644 --- a/os/net/routing/rpl-lite/rpl-nbr-policy.c +++ b/os/net/routing/rpl-lite/rpl-nbr-policy.c @@ -65,19 +65,7 @@ static int num_parents; /* all nodes that are possible parents */ static int num_free; static linkaddr_t *worst_rank_nbr_lladdr; /* lladdr of the the neighbor with the worst rank */ static rpl_rank_t worst_rank; -/*---------------------------------------------------------------------------*/ -#if LOG_DBG_ENABLED -/* Print out state periodically */ -static void update_state(void); -static struct ctimer periodic_timer; -static int timer_init = 0; -static void -handle_periodic_timer(void *ptr) -{ - update_state(); - ctimer_restart(&periodic_timer); -} -#endif /* LOG_DBG_ENABLED */ + /*---------------------------------------------------------------------------*/ static void update_state(void) @@ -87,14 +75,6 @@ update_state(void) rpl_rank_t nbr_rank; int num_used = 0; -#if LOG_DBG_ENABLED - if(!timer_init) { - timer_init = 1; - ctimer_set(&periodic_timer, 60 * CLOCK_SECOND, - &handle_periodic_timer, NULL); - } -#endif /* LOG_DBG_ENABLED */ - worst_rank = 0; worst_rank_nbr_lladdr = NULL; num_parents = 0; diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index 5da6edc67..9bb98ed60 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -514,9 +514,9 @@ handle_periodic_timer(void *ptr) the meaning of last_advertised_rank changes with time */ rpl_dag_update_state(); -#if LOG_INFO_ENABLED - rpl_neighbor_print_list("Periodic"); -#endif /* LOG_INFO_ENABLED */ + if(LOG_INFO_ENABLED) { + rpl_neighbor_print_list("Periodic"); + } ctimer_reset(&periodic_timer); }