jsoninfo: fix a Coverity warning
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 Sep 2015 11:24:24 +0000 (13:24 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 Sep 2015 11:37:40 +0000 (13:37 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 7bb9d86..98eb993 100644 (file)
@@ -851,12 +851,14 @@ extern struct interfaceName * sgwTunnel6InterfaceNames;
  * @param fmtv the format for printing
  */
 static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
+  struct interfaceName * sgwTunnelInterfaceNames;
+
   abuf_json_mark_array_entry(true, abuf);
   abuf_json_mark_object(true, true, abuf, ipv6 ? "ipv6" : "ipv4");
 
-  if (olsr_cnf->smart_gw_active) {
+  sgwTunnelInterfaceNames = !ipv6 ? sgwTunnel4InterfaceNames : sgwTunnel6InterfaceNames;
+  if (olsr_cnf->smart_gw_active && sgwTunnelInterfaceNames) {
     struct gateway_entry * current_gw = olsr_get_inet_gateway(ipv6);
-    struct interfaceName * sgwTunnelInterfaceNames = !ipv6 ? sgwTunnel4InterfaceNames : sgwTunnel6InterfaceNames;
     int i;
     for (i = 0; i < olsr_cnf->smart_gw_use_count; i++) {
       bool selected;
@@ -871,7 +873,7 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
       struct ipaddr_str tunnelGwStr;
       const char * tunnelGw;
 
-      struct gateway_entry * gw = node ? node->gw : NULL;
+      struct gateway_entry * gw = node->gw;
       struct tc_entry* tc;
 
       if (!gw) {