From c31a793b486d0bc34e498fdf703fd7120afbecf0 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Wed, 27 Sep 2017 23:38:19 +0200 Subject: [PATCH] scan-build: cleanup some warnings 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 | 10 ++++++---- lib/zclient.c | 2 +- ospfd/ospf_vty.c | 7 +++---- pimd/pim_nht.c | 2 +- zebra/zebra_rnh.c | 1 + 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/babeld/babel_main.c b/babeld/babel_main.c index 6a8f9bb75f..239ab71f06 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -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 diff --git a/lib/zclient.c b/lib/zclient.c index e30f166dde..0b06dbacba 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -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; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 4cbd4b4a99..3ffc68191c 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -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, diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 1e88ff13ff..7a380796a1 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -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)); diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 4bc9caca5d..fabb4f9e14 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -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; } -- 2.39.5