From d89a4ef4fd136a7d94ff6cc3e182506b9b9118e7 Mon Sep 17 00:00:00 2001 From: nvt Date: Wed, 4 Jan 2012 14:13:54 +0100 Subject: [PATCH] Simplified best_dag function and fixed the previous incomplete commit. --- core/net/rpl/rpl-of-etx.c | 22 +++++----------------- core/net/rpl/rpl-private.h | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/core/net/rpl/rpl-of-etx.c b/core/net/rpl/rpl-of-etx.c index 6f82c1ad3..466d86ca6 100644 --- a/core/net/rpl/rpl-of-etx.c +++ b/core/net/rpl/rpl-of-etx.c @@ -137,27 +137,15 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank) static rpl_dag_t * best_dag(rpl_dag_t *d1, rpl_dag_t *d2) { - if(d1->grounded) { - if (!d2->grounded) { - return d1; - } - } else if(d2->grounded) { - return d2; + if(d1->grounded != d2->grounded) { + return d1->grounded ? d1 : d2; } - if(d1->preference < d2->preference) { - return d2; - } else { - if(d1->preference > d2->preference) { - return d1; - } + if(d1->preference != d2->preference) { + return d1->preference > d2->preference ? d1 : d2; } - if(d2->rank < d1->rank) { - return d2; - } else { - return d1; - } + return d1->rank < d2->rank ? d1 : d2; } static rpl_parent_t * diff --git a/core/net/rpl/rpl-private.h b/core/net/rpl/rpl-private.h index 3ee258741..a4fb43b83 100644 --- a/core/net/rpl/rpl-private.h +++ b/core/net/rpl/rpl-private.h @@ -55,7 +55,7 @@ /*---------------------------------------------------------------------------*/ /** \brief Is IPv6 address addr the link-local, all-RPL-nodes multicast address? */ -#define uip_is_addr_linklocal_rplnodes_mcast(a) \ +#define uip_is_addr_linklocal_rplnodes_mcast(addr) \ ((addr)->u8[0] == 0xff) && \ ((addr)->u8[1] == 0x02) && \ ((addr)->u16[1] == 0) && \