[Olsr-dev] [PATCH v1 13/19] gateway: simplify a condition

Ferry Huberts (spam-protected)
Thu Aug 23 15:12:37 CEST 2012


From: Ferry Huberts <(spam-protected)>

Because of the preceding
  if (ipv4) {
    current_ipv4_gw = NULL;
  }
  if (ipv6) {
    current_ipv6_gw = NULL;
  }

The condition(s)
   if (ipvX && entry != current_ipvX_gw
Are effectively
   if (ipvX && entry != NULL
Also, the test
   entry != NULL
was already performed by the enclosing if statement

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/gateway.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gateway.c b/src/gateway.c
index b467c9a..3f91cd7 100644
--- a/src/gateway.c
+++ b/src/gateway.c
@@ -494,11 +494,11 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6)
 
   entry = node2gateway(avl_find(&gateway_tree, originator));
   if (entry != NULL) {
-    if (ipv4 && entry != current_ipv4_gw && entry->ipv4 && (!entry->ipv4nat || olsr_cnf->smart_gw_allow_nat)) {
+    if (ipv4 && entry->ipv4 && (!entry->ipv4nat || olsr_cnf->smart_gw_allow_nat)) {
       /* valid ipv4 gateway */
       current_ipv4_gw = entry;
     }
-    if (ipv6 && entry != current_ipv6_gw && entry->ipv6) {
+    if (ipv6 && entry->ipv6) {
       /* valid ipv6 gateway */
       current_ipv6_gw = entry;
     }
-- 
1.7.11.4





More information about the Olsr-dev mailing list