gateway: simplify a condition
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 23 Aug 2012 12:15:54 +0000 (14:15 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 24 Aug 2012 08:50:04 +0000 (10:50 +0200)
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 <ferry.huberts@pelagic.nl>
Reviewed-by: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
src/gateway.c

index b467c9a..3f91cd7 100644 (file)
@@ -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;
     }