sgw: gw NULL check no longer needed when using OLSR_FOR_ALL_GWS
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 23 May 2016 10:41:49 +0000 (12:41 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 23 May 2016 10:48:59 +0000 (12:48 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/httpinfo/src/olsrd_httpinfo.c
src/gateway.c
src/gateway_list.c

index 1882213..d6a060b 100644 (file)
@@ -1566,50 +1566,48 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
 
     current_gw = olsr_get_inet_gateway(false);
     OLSR_FOR_ALL_GWS(&list->head, gw) {
-      if (gw) {
-        struct gwtextbuffer gwbuf;
-        bool is_current = (current_gw && (gw->gw == current_gw));
-
-        if (is_current) {
-          abuf_puts(abuf, "    <tr bgcolor=\"lime\">\n");
-        } else {
-          abuf_puts(abuf, "    <tr>\n");
-        }
+      struct gwtextbuffer gwbuf;
+      bool is_current = (current_gw && (gw->gw == current_gw));
+
+      if (is_current) {
+        abuf_puts(abuf, "    <tr bgcolor=\"lime\">\n");
+      } else {
+        abuf_puts(abuf, "    <tr>\n");
+      }
 
-        if (!gw->gw) {
-          int i;
-          for (i = 0; i < 8; i++) {
-            abuf_puts(abuf, "      <td></td>\n");
-          }
-        } else {
-          struct tc_entry* tc = olsr_lookup_tc_entry(&gw->gw->originator);
-          olsr_linkcost etx = ROUTE_COST_BROKEN;
-          struct lqtextbuffer lcbuf;
-          if (tc) {
-            etx = tc->path_cost;
-          }
-
-          abuf_appendf(abuf, "      <td>%s</td>\n", inet_ntop(ipv6 ? AF_INET6 : AF_INET, &gw->gw->originator, buf, sizeof(buf)));
-          abuf_appendf(abuf, "      <td>%s</td>\n", olsr_ip_prefix_to_string(&gw->gw->external_prefix));
-          abuf_appendf(abuf, "      <td>%u</td>\n", gw->gw->uplink);
-          abuf_appendf(abuf, "      <td>%u</td>\n", gw->gw->downlink);
-          abuf_appendf(abuf, "      <td>%s</td>\n", get_linkcost_text(etx, true, &lcbuf));
-          abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv4 ? "yes" : "no");
-          abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv4nat ? "yes" : "no");
-          abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv6 ? "yes" : "no");
+      if (!gw->gw) {
+        int i;
+        for (i = 0; i < 8; i++) {
+          abuf_puts(abuf, "      <td></td>\n");
         }
-        if (!gw->tunnel) {
-          int i;
-          for (i = 0; i < 2; i++) {
-            abuf_puts(abuf, "      <td></td>\n");
-          }
-        } else {
-          abuf_appendf(abuf, "      <td>%s</td>\n", gw->tunnel->if_name);
-          abuf_appendf(abuf, "      <td>%s</td>\n", inet_ntop(ipv6 ? AF_INET6 : AF_INET, &gw->tunnel->target, buf, sizeof(buf)));
+      } else {
+        struct tc_entry* tc = olsr_lookup_tc_entry(&gw->gw->originator);
+        olsr_linkcost etx = ROUTE_COST_BROKEN;
+        struct lqtextbuffer lcbuf;
+        if (tc) {
+          etx = tc->path_cost;
+        }
+
+        abuf_appendf(abuf, "      <td>%s</td>\n", inet_ntop(ipv6 ? AF_INET6 : AF_INET, &gw->gw->originator, buf, sizeof(buf)));
+        abuf_appendf(abuf, "      <td>%s</td>\n", olsr_ip_prefix_to_string(&gw->gw->external_prefix));
+        abuf_appendf(abuf, "      <td>%u</td>\n", gw->gw->uplink);
+        abuf_appendf(abuf, "      <td>%u</td>\n", gw->gw->downlink);
+        abuf_appendf(abuf, "      <td>%s</td>\n", get_linkcost_text(etx, true, &lcbuf));
+        abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv4 ? "yes" : "no");
+        abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv4nat ? "yes" : "no");
+        abuf_appendf(abuf, "      <td>%s</td>\n", gw->gw->ipv6 ? "yes" : "no");
+      }
+      if (!gw->tunnel) {
+        int i;
+        for (i = 0; i < 2; i++) {
+          abuf_puts(abuf, "      <td></td>\n");
         }
-        abuf_appendf(abuf, "      <td>%s</td>\n", get_gwcost_text(!gw->gw ? INT64_MAX : gw->gw->path_cost, &gwbuf));
-        abuf_puts(abuf, "    </tr>\n");
+      } else {
+        abuf_appendf(abuf, "      <td>%s</td>\n", gw->tunnel->if_name);
+        abuf_appendf(abuf, "      <td>%s</td>\n", inet_ntop(ipv6 ? AF_INET6 : AF_INET, &gw->tunnel->target, buf, sizeof(buf)));
       }
+      abuf_appendf(abuf, "      <td>%s</td>\n", get_gwcost_text(!gw->gw ? INT64_MAX : gw->gw->path_cost, &gwbuf));
+      abuf_puts(abuf, "    </tr>\n");
     } OLSR_FOR_ALL_GWS_END(gw);
     abuf_puts(abuf, "  </tbody>\n");
     abuf_puts(abuf, "</table>\n");
index 6e15989..50947cb 100644 (file)
@@ -1015,7 +1015,7 @@ void olsr_cleanup_gateways(void) {
 
   /* remove all active IPv4 gateways (should be at most 1 now) */
   OLSR_FOR_ALL_GWS(&gw_list_ipv4.head, gw) {
-    if (gw && gw->gw) {
+    if (gw->gw) {
       olsr_delete_gateway_entry(&gw->gw->originator, FORCE_DELETE_GW_ENTRY, true);
     }
   }
@@ -1023,7 +1023,7 @@ void olsr_cleanup_gateways(void) {
 
   /* remove all active IPv6 gateways (should be at most 1 now) */
   OLSR_FOR_ALL_GWS(&gw_list_ipv6.head, gw) {
-    if (gw && gw->gw) {
+    if (gw->gw) {
       olsr_delete_gateway_entry(&gw->gw->originator, FORCE_DELETE_GW_ENTRY, true);
     }
   }
index c979133..94b3f03 100644 (file)
@@ -97,7 +97,7 @@ struct gw_container_entry * olsr_gw_list_find(struct gw_list * list, struct gate
        assert(entry);
 
        OLSR_FOR_ALL_GWS(&list->head, gw) {
-               if (gw && gw->gw && (gw->gw == entry)) {
+               if (gw->gw && (gw->gw == entry)) {
                        return gw;
                }
        }