From 21cf6b211badb0a4a2de8995e562f815255c2ab7 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 17:56:23 +0200 Subject: [PATCH 01/17] rfapi: avoid calling NULL() function. Keep the execution flow, bug log errors. Signed-off-by: Vincent Jardin --- bgpd/rfapi/rfapi_import.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index d963a759ac..083a549307 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -3861,6 +3861,20 @@ void rfapiBgpInfoFilteredImportVPN( VNC_ITRCCK; } +static void rfapiBgpInfoFilteredImportBadSafi( + struct rfapi_import_table *import_table, int action, struct peer *peer, + void *rfd, /* set for looped back routes */ + struct prefix *p, + struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */ + afi_t afi, struct prefix_rd *prd, + struct attr *attr, /* part of bgp_info */ + u_char type, /* part of bgp_info */ + u_char sub_type, /* part of bgp_info */ + uint32_t *label) /* part of bgp_info */ +{ + vnc_zlog_debug_verbose("%s: Error, bad safi", __func__); +} + static rfapi_bi_filtered_import_f * rfapiBgpInfoFilteredImportFunction(safi_t safi) { @@ -3874,7 +3888,7 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi) default: /* not expected */ zlog_err("%s: bad safi %d", __func__, safi); - return NULL; + return rfapiBgpInfoFilteredImportBadSafi; } } From 3981b5c7f3232086aecd35e56bbeb4b5116c8469 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 18:20:12 +0200 Subject: [PATCH 02/17] ospf6d: fix clang warning, NULL() calls Avoid show() methods from being a NULL function when it is called. Meanwhile, I did const'ify the handlers so only its debug field can be changed. Signed-off-by: Vincent Jardin --- ospf6d/ospf6_abr.c | 22 +++++++------- ospf6d/ospf6_asbr.c | 9 ++++-- ospf6d/ospf6_intra.c | 42 ++++++++++++++++++++------- ospf6d/ospf6_lsa.c | 68 +++++++++++++++++++++++++------------------- ospf6d/ospf6_lsa.h | 29 ++++++++++++------- 5 files changed, 107 insertions(+), 63 deletions(-) diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 36528d063c..d270b9547e 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -1110,19 +1110,21 @@ void install_element_ospf6_debug_abr(void) } struct ospf6_lsa_handler inter_prefix_handler = { - OSPF6_LSTYPE_INTER_PREFIX, - "Inter-Prefix", - "IAP", - ospf6_inter_area_prefix_lsa_show, - ospf6_inter_area_prefix_lsa_get_prefix_str, + .lh_type = OSPF6_LSTYPE_INTER_PREFIX, + .lh_name = "Inter-Prefix", + .lh_short_name = "IAP", + .lh_show = ospf6_inter_area_prefix_lsa_show, + .lh_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str, + .lh_debug = 0 }; struct ospf6_lsa_handler inter_router_handler = { - OSPF6_LSTYPE_INTER_ROUTER, - "Inter-Router", - "IAR", - ospf6_inter_area_router_lsa_show, - ospf6_inter_area_router_lsa_get_prefix_str, + .lh_type = OSPF6_LSTYPE_INTER_ROUTER, + .lh_name = "Inter-Router", + .lh_short_name = "IAR", + .lh_show = ospf6_inter_area_router_lsa_show, + .lh_get_prefix_str = ospf6_inter_area_router_lsa_get_prefix_str, + .lh_debug = 0 }; void ospf6_abr_init(void) diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index de20fbc3ab..e3ceee2439 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1234,8 +1234,13 @@ DEFUN (show_ipv6_ospf6_redistribute, } struct ospf6_lsa_handler as_external_handler = { - OSPF6_LSTYPE_AS_EXTERNAL, "AS-External", "ASE", - ospf6_as_external_lsa_show, ospf6_as_external_lsa_get_prefix_str}; + .lh_type = OSPF6_LSTYPE_AS_EXTERNAL, + .lh_name = "AS-External", + .lh_short_name = "ASE", + .lh_show = ospf6_as_external_lsa_show, + .lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str, + .lh_debug = 0 +}; void ospf6_asbr_init(void) { diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index e4644bb09f..a2caeccb86 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1630,21 +1630,41 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) oa->name); } -struct ospf6_lsa_handler router_handler = {OSPF6_LSTYPE_ROUTER, "Router", "Rtr", - ospf6_router_lsa_show, - ospf6_router_lsa_get_nbr_id}; +struct ospf6_lsa_handler router_handler = { + .lh_type = OSPF6_LSTYPE_ROUTER, + .lh_name = "Router", + .lh_short_name = "Rtr", + .lh_show = ospf6_router_lsa_show, + .lh_get_prefix_str = ospf6_router_lsa_get_nbr_id, + .lh_debug = 0 +}; -struct ospf6_lsa_handler network_handler = {OSPF6_LSTYPE_NETWORK, "Network", - "Net", ospf6_network_lsa_show, - ospf6_network_lsa_get_ar_id}; +struct ospf6_lsa_handler network_handler = { + .lh_type = OSPF6_LSTYPE_NETWORK, + .lh_name = "Network", + .lh_short_name = "Net", + .lh_show = ospf6_network_lsa_show, + .lh_get_prefix_str = ospf6_network_lsa_get_ar_id, + .lh_debug = 0 +}; -struct ospf6_lsa_handler link_handler = {OSPF6_LSTYPE_LINK, "Link", "Lnk", - ospf6_link_lsa_show, - ospf6_link_lsa_get_prefix_str}; +struct ospf6_lsa_handler link_handler = { + .lh_type = OSPF6_LSTYPE_LINK, + .lh_name = "Link", + .lh_short_name = "Lnk", + .lh_show = ospf6_link_lsa_show, + .lh_get_prefix_str = ospf6_link_lsa_get_prefix_str, + .lh_debug = 0 +}; struct ospf6_lsa_handler intra_prefix_handler = { - OSPF6_LSTYPE_INTRA_PREFIX, "Intra-Prefix", "INP", - ospf6_intra_prefix_lsa_show, ospf6_intra_prefix_lsa_get_prefix_str}; + .lh_type = OSPF6_LSTYPE_INTRA_PREFIX, + .lh_name = "Intra-Prefix", + .lh_short_name = "INP", + .lh_show = ospf6_intra_prefix_lsa_show, + .lh_get_prefix_str = ospf6_intra_prefix_lsa_get_prefix_str, + .lh_debug = 0 +}; void ospf6_intra_init(void) { diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index a0dad9344a..82f75b153e 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -68,19 +68,25 @@ static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) return 0; } -struct ospf6_lsa_handler unknown_handler = { - OSPF6_LSTYPE_UNKNOWN, "Unknown", "Unk", ospf6_unknown_lsa_show, NULL}; +static struct ospf6_lsa_handler unknown_handler = { + .lh_type = OSPF6_LSTYPE_UNKNOWN, + .lh_name = "Unknown", + .lh_short_name = "Unk", + .lh_show = ospf6_unknown_lsa_show, + .lh_get_prefix_str = NULL, + .lh_debug = 0 /* No default debug */ +}; -void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler) +void ospf6_install_lsa_handler(const struct ospf6_lsa_handler *handler) { /* type in handler is host byte order */ - int index = handler->type & OSPF6_LSTYPE_FCODE_MASK; - vector_set_index(ospf6_lsa_handler_vector, index, handler); + int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK; + vector_set_index(ospf6_lsa_handler_vector, index, (void *)handler); } -struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type) +const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type) { - struct ospf6_lsa_handler *handler = NULL; + const struct ospf6_lsa_handler *handler = NULL; unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK; if (index >= vector_active(ospf6_lsa_handler_vector)) @@ -97,11 +103,11 @@ struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type) const char *ospf6_lstype_name(u_int16_t type) { static char buf[8]; - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; handler = ospf6_get_lsa_handler(type); if (handler && handler != &unknown_handler) - return handler->name; + return handler->lh_name; snprintf(buf, sizeof(buf), "0x%04hx", ntohs(type)); return buf; @@ -110,11 +116,11 @@ const char *ospf6_lstype_name(u_int16_t type) const char *ospf6_lstype_short_name(u_int16_t type) { static char buf[8]; - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; handler = ospf6_get_lsa_handler(type); if (handler && handler != &unknown_handler) - return handler->short_name; + return handler->lh_short_name; snprintf(buf, sizeof(buf), "0x%04hx", ntohs(type)); return buf; @@ -122,7 +128,7 @@ const char *ospf6_lstype_short_name(u_int16_t type) u_char ospf6_lstype_debug(u_int16_t type) { - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; handler = ospf6_get_lsa_handler(type); return handler->debug; } @@ -369,7 +375,7 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa) { char adv_router[16], id[16]; int type; - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; char buf[64], tmpbuf[80]; int cnt = 0; @@ -389,14 +395,14 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa) ospf6_lstype_short_name(lsa->header->type), id, adv_router, ospf6_lsa_age_current(lsa), (u_long)ntohl(lsa->header->seqnum), - handler->get_prefix_str(lsa, buf, sizeof(buf), 0)); + handler->lh_get_prefix_str(lsa, buf, sizeof(buf), 0)); } else if (type != OSPF6_LSTYPE_UNKNOWN) { sprintf(tmpbuf, "%-4s %-15s%-15s%4hu %8lx", ospf6_lstype_short_name(lsa->header->type), id, adv_router, ospf6_lsa_age_current(lsa), (u_long)ntohl(lsa->header->seqnum)); - while (handler->get_prefix_str(lsa, buf, sizeof(buf), cnt) + while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt) != NULL) { vty_out(vty, "%s %30s\n", tmpbuf, buf); cnt++; @@ -465,7 +471,7 @@ void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa) void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) { char adv_router[64], id[64]; - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; struct timeval now, res; char duration[64]; @@ -490,9 +496,13 @@ void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) vty_out(vty, "Duration: %s\n", duration); handler = ospf6_get_lsa_handler(lsa->header->type); - if (handler->show == NULL) - handler = &unknown_handler; - (*handler->show)(vty, lsa); + + if (handler->lh_show != NULL) + handler->lh_show(vty, lsa); + else { + assert(unknown_handler.lh_show != NULL); + unknown_handler.lh_show(vty, lsa); + } vty_out(vty, "\n"); } @@ -739,22 +749,22 @@ void ospf6_lsa_terminate(void) vector_free(ospf6_lsa_handler_vector); } -static char *ospf6_lsa_handler_name(struct ospf6_lsa_handler *h) +static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h) { static char buf[64]; unsigned int i; - unsigned int size = strlen(h->name); + unsigned int size = strlen(h->lh_name); - if (!strcmp(h->name, "unknown") && h->type != OSPF6_LSTYPE_UNKNOWN) { - snprintf(buf, sizeof(buf), "%#04hx", h->type); + if (!strcmp(h->lh_name, "unknown") && h->lh_type != OSPF6_LSTYPE_UNKNOWN) { + snprintf(buf, sizeof(buf), "%#04hx", h->lh_type); return buf; } for (i = 0; i < MIN(size, sizeof(buf)); i++) { - if (!islower((unsigned char)h->name[i])) - buf[i] = tolower((unsigned char)h->name[i]); + if (!islower((unsigned char)h->lh_name[i])) + buf[i] = tolower((unsigned char)h->lh_name[i]); else - buf[i] = h->name[i]; + buf[i] = h->lh_name[i]; } buf[size] = '\0'; return buf; @@ -791,7 +801,7 @@ DEFUN (debug_ospf6_lsa_type, strlen(argv[idx_lsa]->arg)) == 0) break; - if (!strcasecmp(argv[idx_lsa]->arg, handler->name)) + if (!strcasecmp(argv[idx_lsa]->arg, handler->lh_name)) break; handler = NULL; } @@ -844,7 +854,7 @@ DEFUN (no_debug_ospf6_lsa_type, strlen(argv[idx_lsa]->arg)) == 0) break; - if (!strcasecmp(argv[idx_lsa]->arg, handler->name)) + if (!strcasecmp(argv[idx_lsa]->arg, handler->lh_name)) break; } @@ -875,7 +885,7 @@ void install_element_ospf6_debug_lsa(void) int config_write_ospf6_debug_lsa(struct vty *vty) { u_int i; - struct ospf6_lsa_handler *handler; + const struct ospf6_lsa_handler *handler; for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) { handler = vector_slot(ospf6_lsa_handler_vector, i); diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h index ef63429fdf..8b6303d23c 100644 --- a/ospf6d/ospf6_lsa.h +++ b/ospf6d/ospf6_lsa.h @@ -137,18 +137,25 @@ struct ospf6_lsa { #define OSPF6_LSA_SEQWRAPPED 0x20 struct ospf6_lsa_handler { - u_int16_t type; /* host byte order */ - const char *name; - const char *short_name; - int (*show)(struct vty *, struct ospf6_lsa *); - char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen, - int pos); + const struct { + u_int16_t type; /* host byte order */ + const char *name; + const char *short_name; + int (*show)(struct vty *, struct ospf6_lsa *); + char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen, + int pos); + } s; +#define lh_type s.type +#define lh_name s.name +#define lh_short_name s.short_name +#define lh_show s.show +#define lh_get_prefix_str s.get_prefix_str u_char debug; +#define lh_debug debug }; -extern struct ospf6_lsa_handler unknown_handler; -#define OSPF6_LSA_IS_KNOWN(type) \ - (ospf6_get_lsa_handler(type) != &unknown_handler ? 1 : 0) +#define OSPF6_LSA_IS_KNOWN(t) \ + (ospf6_get_lsa_handler(t).lh_type != OSPF6_LSTYPE_UNKNOWN ? 1 : 0) extern vector ospf6_lsa_handler_vector; @@ -237,8 +244,8 @@ extern int ospf6_lsa_checksum_valid(struct ospf6_lsa_header *); extern int ospf6_lsa_prohibited_duration(u_int16_t type, u_int32_t id, u_int32_t adv_router, void *scope); -extern void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler); -extern struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type); +extern void ospf6_install_lsa_handler(const struct ospf6_lsa_handler *handler); +extern const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type); extern void ospf6_lsa_init(void); extern void ospf6_lsa_terminate(void); From 6e38a9ece08f0acdadac3b0df7cc3fcbaa3166bd Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:14:55 +0200 Subject: [PATCH 03/17] ospf6d: fix clang warning troute and tinfo needs to be 0'd Signed-off-by: Vincent Jardin --- ospf6d/ospf6_asbr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index e3ceee2439..c65578c11e 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -438,6 +438,9 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, if (!ospf6_zebra_is_redistribute(type)) return; + memset(&troute, 0, sizeof(troute)); + memset(&tinfo, 0, sizeof(tinfo)); + if (IS_OSPF6_DEBUG_ASBR) { prefix2str(prefix, pbuf, sizeof(pbuf)); zlog_debug("Redistribute %s (%s)", pbuf, ZROUTE_NAME(type)); @@ -457,8 +460,6 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, /* apply route-map */ if (ospf6->rmap[type].map) { - memset(&troute, 0, sizeof(troute)); - memset(&tinfo, 0, sizeof(tinfo)); troute.route_option = &tinfo; tinfo.ifindex = ifindex; tinfo.tag = tag; From 7295876ada80bc62283d44f406ab7550c571d7ea Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:18:36 +0200 Subject: [PATCH 04/17] ospfd: fix clang warning Value stored to 'nbraddr' during its initialization is never read Signed-off-by: Vincent Jardin --- ospfd/ospf_apiserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index c1485abb81..8c1ad5ff0c 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -2322,7 +2322,7 @@ void ospf_apiserver_clients_notify_nsm_change(struct ospf_neighbor *nbr) { struct msg *msg; struct in_addr ifaddr = {.s_addr = 0L}; - struct in_addr nbraddr = {.s_addr = 0L}; + struct in_addr nbraddr; assert(nbr); From 9c5e2b4f61567387f94acbb1783c21abfd56fa72 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:25:24 +0200 Subject: [PATCH 05/17] isisd: fix clang warning tlvs is not used after extracting the last TLV. So, let's tell to the compiler that it is expected. Signed-off-by: Vincent Jardin --- isisd/isis_te.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 70afef1a86..5a4fe82c91 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -223,6 +223,9 @@ uint8_t add_te_subtlvs(uint8_t *buf, struct mpls_te_circuit *mtc) tlvs += size; } + /* Add before this line any other parsing of TLV */ + (void)tlvs; + /* Update SubTLVs length */ mtc->length = subtlvs_len(mtc); From e3df3ba6d4ea294920394a7296a852ebc836c48c Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:28:58 +0200 Subject: [PATCH 06/17] ldpd: fix clang warning size is not used for further parsing. Keep it updated but tell to the compiler that we know it is not used just in case one needs to extend the parsing somedays. Signed-off-by: Vincent Jardin --- ldpd/address.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ldpd/address.c b/ldpd/address.c index 12356a0b49..9c1564a31f 100644 --- a/ldpd/address.c +++ b/ldpd/address.c @@ -88,6 +88,7 @@ send_address(struct nbr *nbr, int af, struct if_addr_head *addr_list, err |= gen_msg_hdr(buf, msg_type, size); size -= LDP_MSG_SIZE; err |= gen_address_list_tlv(buf, af, addr_list, tlv_addr_count); + (void)size; if (err) { address_list_clr(addr_list); ibuf_free(buf); From f38b7f6dd391aefbf87b9448f97da6949ecbfb90 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:37:04 +0200 Subject: [PATCH 07/17] ospfd: fix clang warning us is clearly not used, but let's keep it to have a readable logic. Signed-off-by: Vincent Jardin --- ospfd/ospf_dump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index eca0f85f57..5933f5abfe 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -169,6 +169,7 @@ const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size) if (us >= 1000) { ms = us / 1000; us %= 1000; + (void)us; /* unused */ } if (ms >= 1000) { From 51f7fe8459c7f7c1a10a3d045858cb6ee8f34f88 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:40:36 +0200 Subject: [PATCH 08/17] ripngd: fix clang warning this value len is not used for this vty_out() case. Signed-off-by: Vincent Jardin --- ripngd/ripngd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 0bee9a8bf4..4df1aafe5d 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2010,7 +2010,7 @@ DEFUN (show_ipv6_ripng, len = 28 - len; if (len > 0) - len = vty_out(vty, "%*s", len, " "); + vty_out(vty, "%*s", len, " "); /* from */ if ((rinfo->type == ZEBRA_ROUTE_RIPNG) From 443e99e767706a214f7964aa9b17461a1614a108 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:42:55 +0200 Subject: [PATCH 09/17] eirgpd: fix clang warning opcode is not used. Signed-off-by: Vincent Jardin --- eigrpd/eigrp_packet.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index f7bbcba328..29d95f17b2 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -317,7 +317,6 @@ int eigrp_write(struct thread *thread) struct ip iph; struct msghdr msg; struct iovec iov[2]; - u_int16_t opcode = 0; u_int32_t seqno, ack; int ret; @@ -363,7 +362,6 @@ int eigrp_write(struct thread *thread) * this outgoing packet. */ eigrph = (struct eigrp_header *)STREAM_DATA(ep->s); - opcode = eigrph->opcode; seqno = ntohl(eigrph->sequence); ack = ntohl(eigrph->ack); if (ep->nbr && (ack != ep->nbr->recv_sequence_number)) { @@ -427,9 +425,8 @@ int eigrp_write(struct thread *thread) if (IS_DEBUG_EIGRP_TRANSMIT(0, SEND)) { eigrph = (struct eigrp_header *)STREAM_DATA(ep->s); - opcode = eigrph->opcode; zlog_debug("Sending [%s][%d/%d] to [%s] via [%s] ret [%d].", - lookup_msg(eigrp_packet_type_str, opcode, NULL), + lookup_msg(eigrp_packet_type_str, eigrph->opcode, NULL), seqno, ack, inet_ntoa(ep->dst), IF_NAME(ei), ret); } From 8881d722da1adac3a04949a63a85e23689e9b3eb Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:43:59 +0200 Subject: [PATCH 10/17] rfapi: fix clang warning When DEBUG_L2_EXTRA is not set, clang emits a warning because rc is not used. Signed-off-by: Vincent Jardin --- bgpd/rfapi/rfapi_monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 6a7595443a..47a72d75fd 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -1378,6 +1378,8 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, #if DEBUG_L2_EXTRA vnc_zlog_debug_verbose("%s: inserted rfd=%p mon_eth=%p, rc=%d", __func__, rfd, val, rc); +#else + (void)rc; #endif /* From 49b6be9bd4ff7ceef3d9751172ca4facf4bd9926 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:45:10 +0200 Subject: [PATCH 11/17] bgpd: fix clang warning Remove stored value to llen that is never used. Signed-off-by: Vincent Jardin --- bgpd/bgp_label.c | 1 - 1 file changed, 1 deletion(-) diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index ad7411990e..06c314de03 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -225,7 +225,6 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, for (; pnt < lim; pnt += psize) { /* Clear prefix structure. */ memset(&p, 0, sizeof(struct prefix)); - llen = 0; if (addpath_encoded) { From 649579afb38ed0605285799aa5b51db714eeb15b Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:46:24 +0200 Subject: [PATCH 12/17] lib: fix clang warning Properly initialize to avoid "Branch condition evaluates to a garbage value" warning. Signed-off-by: Vincent Jardin --- lib/ptm_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c index f50d1e2989..e881d49225 100644 --- a/lib/ptm_lib.c +++ b/lib/ptm_lib.c @@ -330,7 +330,7 @@ int ptm_lib_process_msg(ptm_lib_handle_t *hdl, int fd, char *inbuf, int inlen, char client_name[32]; int cmd_id, type, ver, msglen; csv_t *csv; - ptm_lib_msg_ctxt_t *p_ctxt; + ptm_lib_msg_ctxt_t *p_ctxt = NULL; len = _ptm_lib_read_ptm_socket(fd, inbuf, PTMLIB_MSG_HDR_LEN); if (len <= 0) From 792fa92ec13274d7bc05bebf9d9eef3ad2b2e0d1 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:47:43 +0200 Subject: [PATCH 13/17] zebra: fix clang warning Set to 0 to avoid "Branch condition evaluates to a garbage value". Signed-off-by: Vincent Jardin --- zebra/rt_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 573f60f4ca..0352dbd7e3 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -267,7 +267,7 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, struct rtattr *tb[RTA_MAX + 1]; u_char flags = 0; struct prefix p; - struct prefix_ipv6 src_p; + struct prefix_ipv6 src_p = {}; vrf_id_t vrf_id = VRF_DEFAULT; char anyaddr[16] = {0}; From 47402c0f919557490474cee598405854c65d4cf5 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:48:55 +0200 Subject: [PATCH 14/17] vtysh: fix clang warning cmd->line shall never be null for these sections. Signed-off-by: Vincent Jardin --- vtysh/vtysh_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 99c05ef79b..8509a8a05a 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -451,7 +451,7 @@ int main(int argc, char **argv, char **env) exit(ret); } - if (dryrun && cmd) { + if (dryrun && cmd && cmd->line) { vtysh_execute("enable"); while (cmd) { struct cmd_rec *cr; @@ -552,7 +552,7 @@ int main(int argc, char **argv, char **env) } /* If eval mode. */ - if (cmd) { + if (cmd && cmd->line) { /* Enter into enable node. */ vtysh_execute("enable"); From e991f75cb8393a386c4ad65452fa23cae31c9bc7 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sun, 8 Oct 2017 23:50:54 +0200 Subject: [PATCH 15/17] bgpd: fix clang warning Same fix than c31a793, alwas get the string so clang does not complain that it can be NULL. Signed-off-by: Vincent Jardin --- bgpd/bgp_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index 6e1a1b6d62..ae9d805b05 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -410,8 +410,8 @@ DEFUN (ip_as_path, char *regstr; /* Retrieve access list name */ - char *alname = - argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; + argv_find(argv, argc, "WORD", &idx); + char *alname = argv[idx]->arg; /* Check the filter type. */ type = argv_find(argv, argc, "deny", &idx) ? AS_FILTER_DENY From 6c86ed54c2f8774ba379b0c1dc328bd1c5addefb Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Mon, 9 Oct 2017 00:06:08 +0200 Subject: [PATCH 16/17] eigrpd: fix clang warning nbr cannot be NULL. Doing such test does confuse clang since we do not have execution case if nbr == NULL. Signed-off-by: Vincent Jardin --- eigrpd/eigrp_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 29d95f17b2..83ff194729 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -169,7 +169,7 @@ int eigrp_check_md5_digest(struct stream *s, struct TLV_MD5_Authentication_Type *auth_TLV; struct eigrp_header *eigrph; - if (nbr && ntohl(nbr->crypt_seqnum) > ntohl(authTLV->key_sequence)) { + if (ntohl(nbr->crypt_seqnum) > ntohl(authTLV->key_sequence)) { zlog_warn( "interface %s: eigrp_check_md5 bad sequence %d (expect %d)", IF_NAME(nbr->ei), ntohl(authTLV->key_sequence), From 85bbc95dc3f3fafde75277dea079b9c87c227881 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Mon, 9 Oct 2017 00:12:01 +0200 Subject: [PATCH 17/17] eigrpd: fix clang warning ei shall never be NULL once we do the lookup. If it is NULL bad things could happen. For instance ei->t_distribute may not be a valid reference. Signed-off-by: Vincent Jardin --- eigrpd/eigrp_filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index 7b9e0de525..b74127aa42 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -187,6 +187,7 @@ void eigrp_distribute_update(struct distribute *dist) break; } } + assert(ei != NULL); /* Access-list for interface in */ if (dist->list[DISTRIBUTE_V4_IN]) {