From 36de6e0e1ea886edd0ff7f706a5e8fc81ca9d1e6 Mon Sep 17 00:00:00 2001 From: "F. Aragon" Date: Mon, 17 Sep 2018 18:22:59 +0200 Subject: [PATCH] bgpd isisd ldpd lib: const drop fixes (SA) Can be detected with e.g. ./configure CFLAGS=-Wcast-qual CC=clang Signed-off-by: F. Aragon --- bgpd/bgp_attr.c | 12 ++++++------ bgpd/bgp_flowspec_vty.c | 2 +- isisd/isis_redist.c | 6 +++--- isisd/isis_spf_private.h | 4 ++-- ldpd/adjacency.c | 8 ++++---- ldpd/interface.c | 2 +- ldpd/l2vpn.c | 4 ++-- lib/command.c | 4 ++-- lib/if.c | 8 ++++---- lib/if.h | 2 +- lib/srcdest_table.c | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index a603bbcd8b..a4e8221d6c 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -260,11 +260,11 @@ void bgp_attr_flush_encap(struct attr *attr) * * This algorithm could be made faster if needed */ -static int encap_same(struct bgp_attr_encap_subtlv *h1, - struct bgp_attr_encap_subtlv *h2) +static int encap_same(const struct bgp_attr_encap_subtlv *h1, + const struct bgp_attr_encap_subtlv *h2) { - struct bgp_attr_encap_subtlv *p; - struct bgp_attr_encap_subtlv *q; + const struct bgp_attr_encap_subtlv *p; + const struct bgp_attr_encap_subtlv *q; if (h1 == h2) return 1; @@ -357,8 +357,8 @@ static unsigned int encap_hash_key_make(void *p) static int encap_hash_cmp(const void *p1, const void *p2) { - return encap_same((struct bgp_attr_encap_subtlv *)p1, - (struct bgp_attr_encap_subtlv *)p2); + return encap_same((const struct bgp_attr_encap_subtlv *)p1, + (const struct bgp_attr_encap_subtlv *)p2); } static void encap_init(void) diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 978ce6bf4e..faa88f9850 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -519,7 +519,7 @@ DEFUN (bgp_fs_local_install_ifname, { struct bgp *bgp = VTY_GET_CONTEXT(bgp); int idx = 0; - const char *no = strmatch(argv[0]->text, (char *)"no") ? "no" : NULL; + const char *no = strmatch(argv[0]->text, "no") ? "no" : NULL; char *ifname = argv_find(argv, argc, "INTERFACE", &idx) ? argv[idx]->arg : NULL; diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index ab7584ed3e..6564149a43 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -171,8 +171,7 @@ static void isis_redist_update_ext_reach(struct isis_area *area, int level, if (redist->map_name) { map_ret = - route_map_apply(redist->map, (struct prefix *)p, - RMAP_ISIS, &area_info); + route_map_apply(redist->map, p, RMAP_ISIS, &area_info); if (map_ret == RMAP_DENYMATCH) area_info.distance = 255; } @@ -441,7 +440,8 @@ static void isis_redist_set(struct isis_area *area, int level, int family, } isis_redist_update_ext_reach(area, level, redist, p, - (struct prefix_ipv6 *)src_p, info); + (const struct prefix_ipv6 *)src_p, + info); } } diff --git a/isisd/isis_spf_private.h b/isisd/isis_spf_private.h index af552e0ed1..19e129ba90 100644 --- a/isisd/isis_spf_private.h +++ b/isisd/isis_spf_private.h @@ -106,8 +106,8 @@ static int isis_vertex_queue_hash_cmp(const void *a, const void *b) if (prefix_cmp(&va->N.ip.dest, &vb->N.ip.dest)) return 0; - return prefix_cmp((struct prefix *)&va->N.ip.src, - (struct prefix *)&vb->N.ip.src) == 0; + return prefix_cmp((const struct prefix *)&va->N.ip.src, + (const struct prefix *)&vb->N.ip.src) == 0; } return memcmp(va->N.id, vb->N.id, ISIS_SYS_ID_LEN + 1) == 0; diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 7e4f0fd78b..0bdd2423c7 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -60,11 +60,11 @@ adj_compare(const struct adj *a, const struct adj *b) switch (a->source.type) { case HELLO_LINK: - if (if_cmp_name_func((char *)a->source.link.ia->iface->name, - (char *)b->source.link.ia->iface->name) < 0) + if (if_cmp_name_func(a->source.link.ia->iface->name, + b->source.link.ia->iface->name) < 0) return (-1); - if (if_cmp_name_func((char *)a->source.link.ia->iface->name, - (char *)b->source.link.ia->iface->name) > 0) + if (if_cmp_name_func(a->source.link.ia->iface->name, + b->source.link.ia->iface->name) > 0) return (1); return (ldp_addrcmp(a->source.link.ia->af, &a->source.link.src_addr, &b->source.link.src_addr)); diff --git a/ldpd/interface.c b/ldpd/interface.c index b25be43a5c..8b45703d22 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -45,7 +45,7 @@ RB_GENERATE(iface_head, iface, entry, iface_compare) static __inline int iface_compare(const struct iface *a, const struct iface *b) { - return (if_cmp_name_func((char *)a->name, (char *)b->name)); + return if_cmp_name_func(a->name, b->name); } struct iface * diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 1cfeae3092..7f2e396a7f 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -119,7 +119,7 @@ l2vpn_exit(struct l2vpn *l2vpn) static __inline int l2vpn_if_compare(const struct l2vpn_if *a, const struct l2vpn_if *b) { - return (if_cmp_name_func((char *)a->ifname, (char *)b->ifname)); + return if_cmp_name_func(a->ifname, b->ifname); } struct l2vpn_if * @@ -182,7 +182,7 @@ l2vpn_if_update(struct l2vpn_if *lif) static __inline int l2vpn_pw_compare(const struct l2vpn_pw *a, const struct l2vpn_pw *b) { - return (if_cmp_name_func((char *)a->ifname, (char *)b->ifname)); + return if_cmp_name_func(a->ifname, b->ifname); } struct l2vpn_pw * diff --git a/lib/command.c b/lib/command.c index 26afc762fb..a594adb319 100644 --- a/lib/command.c +++ b/lib/command.c @@ -618,8 +618,8 @@ static int cmd_try_do_shortcut(enum node_type node, char *first_word) */ static int compare_completions(const void *fst, const void *snd) { - struct cmd_token *first = *(struct cmd_token **)fst, - *secnd = *(struct cmd_token **)snd; + const struct cmd_token *first = *(const struct cmd_token * const *)fst, + *secnd = *(const struct cmd_token * const *)snd; return strcmp(first->text, secnd->text); } diff --git a/lib/if.c b/lib/if.c index 2f2073c0a1..824af9f9f6 100644 --- a/lib/if.c +++ b/lib/if.c @@ -63,7 +63,7 @@ int ptm_enable = 0; * before all numbers. Examples: de0 < de1, de100 < fxp0 < xl0, devpty < * devpty0, de0 < del0 */ -int if_cmp_name_func(char *p1, char *p2) +int if_cmp_name_func(const char *p1, const char *p2) { unsigned int l1, l2; long int x1, x2; @@ -99,8 +99,8 @@ int if_cmp_name_func(char *p1, char *p2) if (!*p2) return 1; - x1 = strtol(p1, &p1, 10); - x2 = strtol(p2, &p2, 10); + x1 = strtol(p1, (char **)&p1, 10); + x2 = strtol(p2, (char **)&p2, 10); /* let's compare numbers now */ if (x1 < x2) @@ -121,7 +121,7 @@ int if_cmp_name_func(char *p1, char *p2) static int if_cmp_func(const struct interface *ifp1, const struct interface *ifp2) { - return if_cmp_name_func((char *)ifp1->name, (char *)ifp2->name); + return if_cmp_name_func(ifp1->name, ifp2->name); } static int if_cmp_index_func(const struct interface *ifp1, diff --git a/lib/if.h b/lib/if.h index a861cf2d85..7c7394fe6d 100644 --- a/lib/if.h +++ b/lib/if.h @@ -455,7 +455,7 @@ struct nbr_connected { #endif /* IFF_VIRTUAL */ /* Prototypes. */ -extern int if_cmp_name_func(char *, char *); +extern int if_cmp_name_func(const char *p1, const char *p2); /* * Passing in VRF_UNKNOWN is a valid thing to do, unless we diff --git a/lib/srcdest_table.c b/lib/srcdest_table.c index 4497faf6fc..e49735192d 100644 --- a/lib/srcdest_table.c +++ b/lib/srcdest_table.c @@ -301,5 +301,5 @@ const char *srcdest_rnode2str(struct route_node *rn, char *str, int size) const struct prefix *dst_p, *src_p; srcdest_rnode_prefixes(rn, &dst_p, &src_p); - return srcdest2str(dst_p, (struct prefix_ipv6*)src_p, str, size); + return srcdest2str(dst_p, (const struct prefix_ipv6 *)src_p, str, size); } -- 2.39.5