From 2b6bd8ca3a3955a407b0553009b05572693cfdf7 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 13 Dec 2023 18:07:38 +0100 Subject: [PATCH 1/2] OSPF: Cleanup some warnings --- proto/ospf/lsalib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/ospf/lsalib.h b/proto/ospf/lsalib.h index eca138d7..77e52ce8 100644 --- a/proto/ospf/lsalib.h +++ b/proto/ospf/lsalib.h @@ -16,8 +16,8 @@ static inline void lsa_hton_hdr(struct ospf_lsa_header *h, struct ospf_lsa_heade static inline void lsa_ntoh_hdr(struct ospf_lsa_header *n, struct ospf_lsa_header *h) { *h = *n; }; static inline void lsa_hton_body(void *h, void *n, u16 len) { ASSERT(h != n); memcpy(n, h, len); }; static inline void lsa_ntoh_body(void *n, void *h, u16 len) { ASSERT(n != h); memcpy(h, n, len); }; -static inline void lsa_hton_body1(void *h, u16 len) { }; -static inline void lsa_ntoh_body1(void *n, u16 len) { }; +static inline void lsa_hton_body1(void *h UNUSED, u16 len UNUSED) { }; +static inline void lsa_ntoh_body1(void *n UNUSED, u16 len UNUSED) { }; #else void lsa_hton_hdr(struct ospf_lsa_header *h, struct ospf_lsa_header *n); void lsa_ntoh_hdr(struct ospf_lsa_header *n, struct ospf_lsa_header *h); From 13c6cf8a7430a6b133e46525256eb5554b3f0a2b Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 22 Jan 2024 06:29:14 +0100 Subject: [PATCH 2/2] Trivial code cleanups --- proto/bfd/bfd.c | 8 ++++---- proto/bfd/packets.c | 24 ++++++++++++------------ proto/bgp/bgp.c | 14 +++++++------- proto/ospf/lsupd.c | 2 +- proto/rip/rip.c | 3 ++- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index 97eb2d9b..adeb729c 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -136,7 +136,7 @@ bfd_merge_options(const struct bfd_iface_config *cf, const struct bfd_options *o .min_tx_int = opts->min_tx_int ?: cf->min_tx_int, .idle_tx_int = opts->idle_tx_int ?: cf->idle_tx_int, .multiplier = opts->multiplier ?: cf->multiplier, - .passive = opts->passive_set ? opts->passive : cf->passive + .passive = opts->passive_set ? opts->passive : cf->passive, }; } @@ -231,7 +231,7 @@ bfd_session_control_tx_timer(struct bfd_session *s, int reset) return; - stop: +stop: tm_stop(s->tx_timer); s->last_tx = 0; } @@ -548,7 +548,7 @@ static struct bfd_iface_config bfd_default_iface = { .min_rx_int = BFD_DEFAULT_MIN_RX_INT, .min_tx_int = BFD_DEFAULT_MIN_TX_INT, .idle_tx_int = BFD_DEFAULT_IDLE_TX_INT, - .multiplier = BFD_DEFAULT_MULTIPLIER + .multiplier = BFD_DEFAULT_MULTIPLIER, }; static inline struct bfd_iface_config * @@ -800,7 +800,7 @@ static struct resclass bfd_request_class = { bfd_request_free, bfd_request_dump, NULL, - NULL + NULL, }; diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c index cb5f0d89..e2ec5988 100644 --- a/proto/bfd/packets.c +++ b/proto/bfd/packets.c @@ -96,12 +96,12 @@ bfd_format_flags(u8 flags, char *buf) } const u8 bfd_auth_type_to_hash_alg[] = { - [BFD_AUTH_NONE] = ALG_UNDEFINED, - [BFD_AUTH_SIMPLE] = ALG_UNDEFINED, - [BFD_AUTH_KEYED_MD5] = ALG_MD5, - [BFD_AUTH_METICULOUS_KEYED_MD5] = ALG_MD5, - [BFD_AUTH_KEYED_SHA1] = ALG_SHA1, - [BFD_AUTH_METICULOUS_KEYED_SHA1] = ALG_SHA1, + [BFD_AUTH_NONE] = ALG_UNDEFINED, + [BFD_AUTH_SIMPLE] = ALG_UNDEFINED, + [BFD_AUTH_KEYED_MD5] = ALG_MD5, + [BFD_AUTH_METICULOUS_KEYED_MD5] = ALG_MD5, + [BFD_AUTH_KEYED_SHA1] = ALG_SHA1, + [BFD_AUTH_METICULOUS_KEYED_SHA1] = ALG_SHA1, }; @@ -151,7 +151,7 @@ bfd_fill_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_c uint hash_len = mac_type_length(pass->alg); /* Increase CSN about one time per second */ - u32 new_time = (u64) current_time() >> 20; + u32 new_time = (u64) current_time() >> 20; if ((new_time != s->tx_csn_time) || meticulous) { s->tx_csn++; @@ -321,7 +321,7 @@ bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final) static int bfd_rx_hook(sock *sk, uint len) { - struct bfd_proto *p = sk->data; + struct bfd_proto *p = sk->data; struct bfd_ctl_packet *pkt = (struct bfd_ctl_packet *) sk->rbuf; const char *err_dsc = NULL; uint err_val = 0; @@ -387,7 +387,7 @@ bfd_rx_hook(sock *sk, uint len) u32 old_tx_int = s->des_min_tx_int; u32 old_rx_int = s->rem_min_rx_int; - s->rem_id= ntohl(pkt->snd_id); + s->rem_id = ntohl(pkt->snd_id); s->rem_state = bfd_pkt_get_state(pkt); s->rem_diag = bfd_pkt_get_diag(pkt); s->rem_demand_mode = pkt->flags & BFD_FLAG_DEMAND; @@ -438,7 +438,7 @@ bfd_open_rx_sk(struct bfd_proto *p, int multihop, int af) sk_start(sk); return sk; - err: +err: sk_log_error(sk, p->p.name); rfree(sk); return NULL; @@ -470,7 +470,7 @@ bfd_open_rx_sk_bound(struct bfd_proto *p, ip_addr local, struct iface *ifa) sk_start(sk); return sk; - err: +err: sk_log_error(sk, p->p.name); rfree(sk); return NULL; @@ -502,7 +502,7 @@ bfd_open_tx_sk(struct bfd_proto *p, ip_addr local, struct iface *ifa) sk_start(sk); return sk; - err: +err: sk_log_error(sk, p->p.name); rfree(sk); return NULL; diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 9d4671af..cd57c32b 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -1126,7 +1126,7 @@ static void bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing connection */ { struct bgp_conn *conn = &p->outgoing_conn; - int hops = p->cf->multihop ? : 1; + int hops = p->cf->multihop ?: 1; DBG("BGP: Connecting\n"); sock *s = sk_new(p->p.pool); @@ -1263,7 +1263,7 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED) return 0; } - hops = p->cf->multihop ? : 1; + hops = p->cf->multihop ?: 1; if (sk_set_ttl(sk, p->cf->ttl_security ? 255 : hops) < 0) goto err; @@ -2245,7 +2245,7 @@ bgp_reconfigure(struct proto *P, struct proto_config *CF) return 1; } -#define TABLE(cf, NAME) ((cf)->NAME ? (cf)->NAME->table : NULL ) +#define TABLE(cf, NAME) ((cf)->NAME ? (cf)->NAME->table : NULL) static int bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *import_changed, int *export_changed) @@ -2377,10 +2377,10 @@ bgp_store_error(struct bgp_proto *p, struct bgp_conn *c, u8 class, u32 code) } static char *bgp_state_names[] = { "Idle", "Connect", "Active", "OpenSent", "OpenConfirm", "Established", "Close" }; -static char *bgp_err_classes[] = { "", "Error: ", "Socket: ", "Received: ", "BGP Error: ", "Automatic shutdown: ", ""}; -static char *bgp_misc_errors[] = { "", "Neighbor lost", "Invalid next hop", "Kernel MD5 auth failed", "No listening socket", "Link down", "BFD session down", "Graceful restart"}; -static char *bgp_auto_errors[] = { "", "Route limit exceeded"}; -static char *bgp_gr_states[] = { "None", "Regular", "Long-lived"}; +static char *bgp_err_classes[] = { "", "Error: ", "Socket: ", "Received: ", "BGP Error: ", "Automatic shutdown: ", "" }; +static char *bgp_misc_errors[] = { "", "Neighbor lost", "Invalid next hop", "Kernel MD5 auth failed", "No listening socket", "Link down", "BFD session down", "Graceful restart" }; +static char *bgp_auto_errors[] = { "", "Route limit exceeded" }; +static char *bgp_gr_states[] = { "None", "Regular", "Long-lived" }; static const char * bgp_last_errmsg(struct bgp_proto *p) diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c index 54c4a069..12c9cfaa 100644 --- a/proto/ospf/lsupd.c +++ b/proto/ospf/lsupd.c @@ -172,7 +172,7 @@ ospf_add_flushed_to_lsrt(struct ospf_proto *p, struct ospf_neighbor *n) WALK_SLIST(en, p->lsal) if ((en->lsa.age == LSA_MAXAGE) && (en->lsa_body != NULL) && lsa_flooding_allowed(en->lsa_type, en->domain, n->ifa) && - lsa_is_acceptable(en->lsa_type, n, p)) + lsa_is_acceptable(en->lsa_type, n, p)) ospf_lsa_lsrt_up(en, n); /* If we found any flushed LSA, we send them ASAP */ diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 1c3509e4..4bfb5756 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -77,6 +77,7 @@ */ #include + #include "rip.h" @@ -1358,7 +1359,7 @@ struct protocol proto_rip = { .shutdown = rip_shutdown, .reconfigure = rip_reconfigure, .get_route_info = rip_get_route_info, - .get_attr = rip_get_attr + .get_attr = rip_get_attr, }; void