]> git.puffer.fish Git - mirror/frr.git/commitdiff
scan-build: cleanup some warnings
authorVincent JARDIN <vincent.jardin@6wind.com>
Wed, 27 Sep 2017 21:38:19 +0000 (23:38 +0200)
committerVincent JARDIN <vincent.jardin@6wind.com>
Mon, 2 Oct 2017 07:14:03 +0000 (09:14 +0200)
Current cleanup is for unset values or variables that are not used anymore.

Regarding ospfd/ospf_vty.c: argv_find()
  we'll never get it NULL, so get coststr = argv[idx]->arg;

babeld/babel_main.c
lib/zclient.c
ospfd/ospf_vty.c
pimd/pim_nht.c
zebra/zebra_rnh.c

index 6a8f9bb75f59f110e1362dde592d18614fa2ad9a..239ab71f066f0a987407fc80a5935fa34bafe574 100644 (file)
@@ -279,8 +279,7 @@ babel_load_state_file(void)
     if(fd >= 0 && rc < 0) {
         zlog_err("unlink(babel-state): %s", safe_strerror(errno));
         /* If we couldn't unlink it, it's probably stale. */
-        close(fd);
-        fd = -1;
+        goto fini;
     }
     if(fd >= 0) {
         char buf[100];
@@ -315,9 +314,12 @@ babel_load_state_file(void)
                 zlog_err("Couldn't parse babel-state.");
             }
         }
-        close(fd);
-        fd = -1;
+        goto fini;
     }
+fini:
+    if (fd >= 0)
+        close(fd);
+    return ;
 }
 
 static void
index e30f166ddeab256fc61458c20d28bcba539ab9df..0b06dbacbaf4c683067d9d6b97c3158c17075da0 100644 (file)
@@ -1619,7 +1619,7 @@ static int zclient_read_sync_response(struct zclient *zclient,
                                      u_int16_t expected_cmd)
 {
        struct stream *s;
-       u_int16_t size;
+       u_int16_t size = -1;
        u_char marker;
        u_char version;
        vrf_id_t vrf_id;
index 4cbd4b4a9939f9d1256503616e5c6f342561fcff..3ffc68191cf56597a991e1ee3c934328f3a2f08d 100644 (file)
@@ -6075,12 +6075,11 @@ DEFUN (ip_ospf_cost,
 
        // get arguments
        char *coststr = NULL, *ifaddr = NULL;
-       coststr = argv_find(argv, argc, "(1-65535)", &idx) ? argv[idx]->arg
-                                                          : NULL;
-       ifaddr = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL;
-
+       argv_find(argv, argc, "(1-65535)", &idx);
+       coststr = argv[idx]->arg;
        cost = strtol(coststr, NULL, 10);
 
+       ifaddr = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL;
        if (ifaddr) {
                if (!inet_aton(ifaddr, &addr)) {
                        vty_out(vty,
index 1e88ff13ff86b7299fc7b19bcd98fc4cc63fbee5..7a380796a1c88b625c2942b8d69761aa6ee0849d 100644 (file)
@@ -194,7 +194,7 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr,
        }
 
        if (up != NULL)
-               up = hash_get(pnc->upstream_hash, up, hash_alloc_intern);
+               hash_get(pnc->upstream_hash, up, hash_alloc_intern);
 
        if (pnc && CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID)) {
                memcpy(out_pnc, pnc, sizeof(struct pim_nexthop_cache));
index 4bc9caca5d0768060101e57becd03a4e565a332c..fabb4f9e14d2243d6934fb6fe0c0da2492cc9da5 100644 (file)
@@ -304,6 +304,7 @@ static void addr2hostprefix(int af, const union g_addr *addr,
                prefix->u.prefix6 = addr->ipv6;
                break;
        default:
+               memset(prefix, 0, sizeof(*prefix));
                zlog_warn("%s: unknown address family %d", __func__, af);
                break;
        }