diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-10-14 15:37:04 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-11-01 14:52:54 +0100 |
commit | 3e236955c9369475872b9b86a58502fa777b50b9 (patch) | |
tree | d43b519c2289a353e56c32b42c402f9fa12d0e13 /proto | |
parent | 17fe57d8dcc89aea520788914b252cf49cf060ff (diff) |
Build: switch on -Wextra, get rid of most of the warnings
There are several unresolved -Wmissing-field-initializers on older
versions of GCC than 5.1, all of them false positive.
Diffstat (limited to 'proto')
-rw-r--r-- | proto/babel/babel.c | 4 | ||||
-rw-r--r-- | proto/babel/babel.h | 2 | ||||
-rw-r--r-- | proto/babel/packets.c | 84 | ||||
-rw-r--r-- | proto/bfd/bfd.c | 6 | ||||
-rw-r--r-- | proto/bfd/packets.c | 4 | ||||
-rw-r--r-- | proto/bgp/attrs.c | 2 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 2 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 4 | ||||
-rw-r--r-- | proto/bgp/packets.c | 29 | ||||
-rw-r--r-- | proto/ospf/dbdes.c | 2 | ||||
-rw-r--r-- | proto/ospf/hello.c | 5 | ||||
-rw-r--r-- | proto/ospf/lsalib.c | 2 | ||||
-rw-r--r-- | proto/ospf/lsalib.h | 2 | ||||
-rw-r--r-- | proto/ospf/lsupd.c | 6 | ||||
-rw-r--r-- | proto/ospf/neighbor.c | 2 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 8 | ||||
-rw-r--r-- | proto/ospf/packet.c | 4 | ||||
-rw-r--r-- | proto/ospf/rt.c | 2 | ||||
-rw-r--r-- | proto/ospf/topology.c | 8 | ||||
-rw-r--r-- | proto/radv/packets.c | 6 | ||||
-rw-r--r-- | proto/radv/radv.c | 2 | ||||
-rw-r--r-- | proto/radv/radv.h | 2 | ||||
-rw-r--r-- | proto/rip/packets.c | 8 | ||||
-rw-r--r-- | proto/rip/rip.c | 4 | ||||
-rw-r--r-- | proto/static/static.c | 4 |
25 files changed, 105 insertions, 99 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c index 9d73a264..38be6909 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -1723,7 +1723,7 @@ babel_dump(struct proto *P) } static void -babel_get_route_info(rte *rte, byte *buf, ea_list *attrs) +babel_get_route_info(rte *rte, byte *buf, ea_list *attrs UNUSED) { buf += bsprintf(buf, " (%d/%d) [%lR]", rte->pref, rte->u.babel.metric, rte->u.babel.router_id); } @@ -1965,7 +1965,7 @@ babel_store_tmp_attrs(struct rte *rt, struct ea_list *attrs) */ static void babel_rt_notify(struct proto *P, struct rtable *table UNUSED, struct network *net, - struct rte *new, struct rte *old, struct ea_list *attrs) + struct rte *new, struct rte *old UNUSED, struct ea_list *attrs UNUSED) { struct babel_proto *p = (void *) P; struct babel_entry *e; diff --git a/proto/babel/babel.h b/proto/babel/babel.h index 481c88a7..6a95d82f 100644 --- a/proto/babel/babel.h +++ b/proto/babel/babel.h @@ -111,7 +111,7 @@ struct babel_iface_config { u16 rxcost; u8 type; u8 check_link; - int port; + uint port; u16 hello_interval; u16 ihu_interval; u16 update_interval; diff --git a/proto/babel/packets.c b/proto/babel/packets.c index 65dd6853..08054832 100644 --- a/proto/babel/packets.c +++ b/proto/babel/packets.c @@ -146,6 +146,7 @@ struct babel_write_state { #define TLV_HDR(tlv,t,l) ({ tlv->type = t; tlv->length = l - sizeof(struct babel_tlv); }) #define TLV_HDR0(tlv,t) TLV_HDR(tlv, t, tlv_data[t].min_length) +#define BYTES(n) ((((uint) n) + 7) / 8) static inline u16 get_time16(const void *p) @@ -161,18 +162,18 @@ put_time16(void *p, u16 v) } static inline ip6_addr -get_ip6_px(const void *p, int plen) +get_ip6_px(const void *p, uint plen) { ip6_addr addr = IPA_NONE; - memcpy(&addr, p, (plen + 7) / 8); + memcpy(&addr, p, BYTES(plen)); return ip6_ntoh(addr); } static inline void -put_ip6_px(void *p, ip6_addr addr, int plen) +put_ip6_px(void *p, ip6_addr addr, uint plen) { addr = ip6_hton(addr); - memcpy(p, &addr, (plen + 7) / 8); + memcpy(p, &addr, BYTES(plen)); } static inline ip6_addr @@ -202,21 +203,21 @@ static int babel_read_update(struct babel_tlv *hdr, union babel_msg *msg, struct static int babel_read_route_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_parse_state *state); static int babel_read_seqno_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_parse_state *state); -static int babel_write_ack(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); -static int babel_write_hello(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); -static int babel_write_ihu(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); -static int babel_write_update(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); -static int babel_write_route_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); -static int babel_write_seqno_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, int max_len); +static uint babel_write_ack(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); +static uint babel_write_hello(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); +static uint babel_write_ihu(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); +static uint babel_write_update(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); +static uint babel_write_route_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); +static uint babel_write_seqno_request(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, uint max_len); struct babel_tlv_data { u8 min_length; int (*read_tlv)(struct babel_tlv *hdr, union babel_msg *m, struct babel_parse_state *state); - int (*write_tlv)(struct babel_tlv *hdr, union babel_msg *m, struct babel_write_state *state, int max_len); + uint (*write_tlv)(struct babel_tlv *hdr, union babel_msg *m, struct babel_write_state *state, uint max_len); void (*handle_tlv)(union babel_msg *m, struct babel_iface *ifa); }; -const static struct babel_tlv_data tlv_data[BABEL_TLV_MAX] = { +static const struct babel_tlv_data tlv_data[BABEL_TLV_MAX] = { [BABEL_TLV_ACK_REQ] = { sizeof(struct babel_tlv_ack_req), babel_read_ack_req, @@ -291,9 +292,9 @@ babel_read_ack_req(struct babel_tlv *hdr, union babel_msg *m, return PARSE_SUCCESS; } -static int +static uint babel_write_ack(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state UNUSED, uint max_len UNUSED) { struct babel_tlv_ack *tlv = (void *) hdr; struct babel_msg_ack *msg = &m->ack; @@ -319,9 +320,9 @@ babel_read_hello(struct babel_tlv *hdr, union babel_msg *m, return PARSE_SUCCESS; } -static int +static uint babel_write_hello(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state UNUSED, uint max_len UNUSED) { struct babel_tlv_hello *tlv = (void *) hdr; struct babel_msg_hello *msg = &m->hello; @@ -363,9 +364,9 @@ babel_read_ihu(struct babel_tlv *hdr, union babel_msg *m, return PARSE_SUCCESS; } -static int +static uint babel_write_ihu(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state UNUSED, uint max_len) { struct babel_tlv_ihu *tlv = (void *) hdr; struct babel_msg_ihu *msg = &m->ihu; @@ -401,9 +402,9 @@ babel_read_router_id(struct babel_tlv *hdr, union babel_msg *m UNUSED, } /* This is called directly from babel_write_update() */ -static int +static uint babel_write_router_id(struct babel_tlv *hdr, u64 router_id, - struct babel_write_state *state, int max_len UNUSED) + struct babel_write_state *state, uint max_len UNUSED) { struct babel_tlv_router_id *tlv = (void *) hdr; @@ -467,10 +468,10 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m, msg->metric = get_u16(&tlv->metric); /* Length of received prefix data without omitted part */ - int len = (tlv->plen + 7)/8 - (int) tlv->omitted; + int len = BYTES(tlv->plen) - (int) tlv->omitted; u8 buf[16] = {}; - if ((len < 0) || (len > TLV_OPT_LENGTH(tlv))) + if ((len < 0) || ((uint) len > TLV_OPT_LENGTH(tlv))) return PARSE_ERROR; switch (tlv->ae) @@ -536,13 +537,13 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m, return PARSE_SUCCESS; } -static int +static uint babel_write_update(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state, uint max_len) { struct babel_tlv_update *tlv = (void *) hdr; struct babel_msg_update *msg = &m->update; - int len0 = 0; + uint len0 = 0; /* * When needed, we write Router-ID TLV before Update TLV and return size of @@ -558,7 +559,7 @@ babel_write_update(struct babel_tlv *hdr, union babel_msg *m, tlv = (struct babel_tlv_update *) NEXT_TLV(tlv); } - int len = sizeof(struct babel_tlv_update) + (msg->plen + 7)/8; + uint len = sizeof(struct babel_tlv_update) + BYTES(msg->plen); if (len0 + len > max_len) return 0; @@ -587,7 +588,7 @@ babel_write_update(struct babel_tlv *hdr, union babel_msg *m, static int babel_read_route_request(struct babel_tlv *hdr, union babel_msg *m, - struct babel_parse_state *state) + struct babel_parse_state *state UNUSED) { struct babel_tlv_route_request *tlv = (void *) hdr; struct babel_msg_route_request *msg = &m->route_request; @@ -612,7 +613,7 @@ babel_read_route_request(struct babel_tlv *hdr, union babel_msg *m, if (tlv->plen > MAX_PREFIX_LENGTH) return PARSE_ERROR; - if (TLV_OPT_LENGTH(tlv) < (tlv->plen + 7)/8) + if (TLV_OPT_LENGTH(tlv) < BYTES(tlv->plen)) return PARSE_ERROR; msg->plen = tlv->plen; @@ -629,14 +630,14 @@ babel_read_route_request(struct babel_tlv *hdr, union babel_msg *m, return PARSE_IGNORE; } -static int +static uint babel_write_route_request(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state UNUSED, uint max_len) { struct babel_tlv_route_request *tlv = (void *) hdr; struct babel_msg_route_request *msg = &m->route_request; - int len = sizeof(struct babel_tlv_route_request) + (msg->plen + 7)/8; + uint len = sizeof(struct babel_tlv_route_request) + BYTES(msg->plen); if (len > max_len) return 0; @@ -687,7 +688,7 @@ babel_read_seqno_request(struct babel_tlv *hdr, union babel_msg *m, if (tlv->plen > MAX_PREFIX_LENGTH) return PARSE_ERROR; - if (TLV_OPT_LENGTH(tlv) < (tlv->plen + 7)/8) + if (TLV_OPT_LENGTH(tlv) < BYTES(tlv->plen)) return PARSE_ERROR; msg->plen = tlv->plen; @@ -704,14 +705,14 @@ babel_read_seqno_request(struct babel_tlv *hdr, union babel_msg *m, return PARSE_IGNORE; } -static int +static uint babel_write_seqno_request(struct babel_tlv *hdr, union babel_msg *m, - struct babel_write_state *state, int max_len) + struct babel_write_state *state UNUSED, uint max_len) { struct babel_tlv_seqno_request *tlv = (void *) hdr; struct babel_msg_seqno_request *msg = &m->seqno_request; - int len = sizeof(struct babel_tlv_seqno_request) + (msg->plen + 7)/8; + uint len = sizeof(struct babel_tlv_seqno_request) + BYTES(msg->plen); if (len > max_len) return 0; @@ -744,11 +745,11 @@ babel_read_tlv(struct babel_tlv *hdr, return tlv_data[hdr->type].read_tlv(hdr, msg, state); } -static int +static uint babel_write_tlv(struct babel_tlv *hdr, union babel_msg *msg, struct babel_write_state *state, - int max_len) + uint max_len) { if ((msg->type <= BABEL_TLV_PADN) || (msg->type >= BABEL_TLV_MAX) || @@ -792,7 +793,7 @@ babel_send_to(struct babel_iface *ifa, ip_addr dest) * * The TLVs in the queue are freed after they are written to the buffer. */ -static int +static uint babel_write_queue(struct babel_iface *ifa, list *queue) { struct babel_proto *p = ifa->proto; @@ -813,6 +814,9 @@ babel_write_queue(struct babel_iface *ifa, list *queue) struct babel_msg_node *msg; WALK_LIST_FIRST(msg, *queue) { + if (pos >= end) + break; + int len = babel_write_tlv((struct babel_tlv *) pos, &msg->msg, &state, end - pos); if (!len) @@ -823,7 +827,7 @@ babel_write_queue(struct babel_iface *ifa, list *queue) sl_free(p->msg_slab, msg); } - int plen = pos - (byte *) pkt; + uint plen = pos - (byte *) pkt; put_u16(&pkt->length, plen - sizeof(struct babel_pkt_header)); return plen; @@ -1027,7 +1031,7 @@ babel_tx_hook(sock *sk) static int -babel_rx_hook(sock *sk, int len) +babel_rx_hook(sock *sk, uint len) { struct babel_iface *ifa = sk->data; struct babel_proto *p = ifa->proto; diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index 5de2f556..e7be6a8a 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -796,7 +796,7 @@ bfd_start_neighbor(struct bfd_proto *p, struct bfd_neighbor *n) } static void -bfd_stop_neighbor(struct bfd_proto *p, struct bfd_neighbor *n) +bfd_stop_neighbor(struct bfd_proto *p UNUSED, struct bfd_neighbor *n) { if (n->neigh) n->neigh->data = NULL; @@ -853,7 +853,7 @@ void pipe_drain(int fd); void pipe_kick(int fd); static int -bfd_notify_hook(sock *sk, int len) +bfd_notify_hook(sock *sk, uint len UNUSED) { struct bfd_proto *p = sk->data; struct bfd_session *s; @@ -1060,7 +1060,7 @@ bfd_preconfig(struct protocol *P UNUSED, struct config *c UNUSED) } static void -bfd_copy_config(struct proto_config *dest, struct proto_config *src) +bfd_copy_config(struct proto_config *dest, struct proto_config *src UNUSED) { struct bfd_config *d = (struct bfd_config *) dest; // struct bfd_config *s = (struct bfd_config *) src; diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c index cb40bcda..deb501fc 100644 --- a/proto/bfd/packets.c +++ b/proto/bfd/packets.c @@ -39,7 +39,7 @@ static inline u8 bfd_pkt_get_diag(struct bfd_ctl_packet *pkt) static inline u8 bfd_pkt_get_state(struct bfd_ctl_packet *pkt) { return pkt->flags >> 6; } -static inline void bfd_pkt_set_state(struct bfd_ctl_packet *pkt, u8 val) +static inline void UNUSED bfd_pkt_set_state(struct bfd_ctl_packet *pkt, u8 val) { pkt->flags = val << 6; } @@ -97,7 +97,7 @@ bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final) #define DROP(DSC,VAL) do { err_dsc = DSC; err_val = VAL; goto drop; } while(0) static int -bfd_rx_hook(sock *sk, int len) +bfd_rx_hook(sock *sk, uint len) { struct bfd_proto *p = sk->data; struct bfd_ctl_packet *pkt = (struct bfd_ctl_packet *) sk->rbuf; diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 6fe34e56..0309c1f7 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -191,7 +191,7 @@ validate_as4_path(struct bgp_proto *p, struct adata *path) } static int -bgp_check_next_hop(struct bgp_proto *p UNUSED, byte *a, int len) +bgp_check_next_hop(struct bgp_proto *p UNUSED, byte *a UNUSED6, int len UNUSED6) { #ifdef IPV6 return IGNORE; diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 2014525e..8ef4b990 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -807,7 +807,7 @@ bgp_find_proto(sock *sk) * closes the new connection by sending a Notification message. */ static int -bgp_incoming_connection(sock *sk, int dummy UNUSED) +bgp_incoming_connection(sock *sk, uint dummy UNUSED) { struct bgp_proto *p; int acc, hops; diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index a865b99d..b4067f3a 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -191,7 +191,7 @@ struct bgp_bucket { #define BGP_RX_BUFFER_EXT_SIZE 65535 #define BGP_TX_BUFFER_EXT_SIZE 65535 -static inline int bgp_max_packet_length(struct bgp_proto *p) +static inline uint bgp_max_packet_length(struct bgp_proto *p) { return p->ext_messages ? BGP_MAX_EXT_MSG_LENGTH : BGP_MAX_MESSAGE_LENGTH; } extern struct linpool *bgp_linpool; @@ -268,7 +268,7 @@ void mrt_dump_bgp_state_change(struct bgp_conn *conn, unsigned old, unsigned new void bgp_schedule_packet(struct bgp_conn *conn, int type); void bgp_kick_tx(void *vconn); void bgp_tx(struct birdsock *sk); -int bgp_rx(struct birdsock *sk, int size); +int bgp_rx(struct birdsock *sk, uint size); const char * bgp_error_dsc(unsigned code, unsigned subcode); void bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned subcode, byte *data, unsigned len); diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 0cf38edf..3e816839 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -191,7 +191,7 @@ bgp_put_cap_gr1(struct bgp_proto *p, byte *buf) } static byte * -bgp_put_cap_gr2(struct bgp_proto *p, byte *buf) +bgp_put_cap_gr2(struct bgp_proto *p UNUSED, byte *buf) { *buf++ = 64; /* Capability 64: Support for graceful restart */ *buf++ = 2; /* Capability data length */ @@ -931,7 +931,7 @@ bgp_parse_options(struct bgp_conn *conn, byte *opt, int len) } static void -bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) +bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len) { struct bgp_conn *other; struct bgp_proto *p = conn->bgp; @@ -944,7 +944,7 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) { bgp_error(conn, 5, fsm_err_subcode[conn->state], NULL, 0); return; } /* Check message contents */ - if (len < 29 || len != 29 + pkt[28]) + if (len < 29 || len != 29U + pkt[28]) { bgp_error(conn, 1, 2, pkt+16, 2); return; } if (pkt[19] != BGP_VERSION) { bgp_error(conn, 2, 1, pkt+19, 1); return; } /* RFC 1771 says 16 bits, draft-09 tells to use 8 */ @@ -1256,16 +1256,15 @@ bgp_do_rx_update(struct bgp_conn *conn, #else /* IPv6 version */ #define DO_NLRI(name) \ - start = x = p->name##_start; \ + x = p->name##_start; \ len = len0 = p->name##_len; \ if (len) \ { \ if (len < 3) { err=9; goto done; } \ af = get_u16(x); \ - sub = x[2]; \ x += 3; \ len -= 3; \ - DBG("\tNLRI AF=%d sub=%d len=%d\n", af, sub, len);\ + DBG("\tNLRI AF=%d sub=%d len=%d\n", af, x[-1], len);\ } \ else \ af = 0; \ @@ -1291,15 +1290,15 @@ bgp_attach_next_hop(rta *a0, byte *x) static void bgp_do_rx_update(struct bgp_conn *conn, - byte *withdrawn, int withdrawn_len, - byte *nlri, int nlri_len, + byte *withdrawn UNUSED, int withdrawn_len, + byte *nlri UNUSED, int nlri_len, byte *attrs, int attr_len) { struct bgp_proto *p = conn->bgp; struct rte_src *src = p->p.main_source; - byte *start, *x; + byte *x; int len, len0; - unsigned af, sub; + unsigned af; rta *a0, *a = NULL; ip_addr prefix; int pxlen, err = 0; @@ -1375,11 +1374,11 @@ bgp_do_rx_update(struct bgp_conn *conn, #endif static void -bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len) +bgp_rx_update(struct bgp_conn *conn, byte *pkt, uint len) { struct bgp_proto *p = conn->bgp; byte *withdrawn, *attrs, *nlri; - int withdrawn_len, attr_len, nlri_len; + uint withdrawn_len, attr_len, nlri_len; BGP_TRACE_RL(&rl_rcv_update, D_PACKETS, "Got UPDATE"); @@ -1525,7 +1524,7 @@ bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned } static void -bgp_rx_notification(struct bgp_conn *conn, byte *pkt, int len) +bgp_rx_notification(struct bgp_conn *conn, byte *pkt, uint len) { struct bgp_proto *p = conn->bgp; if (len < 21) @@ -1591,7 +1590,7 @@ bgp_rx_keepalive(struct bgp_conn *conn) } static void -bgp_rx_route_refresh(struct bgp_conn *conn, byte *pkt, int len) +bgp_rx_route_refresh(struct bgp_conn *conn, byte *pkt, uint len) { struct bgp_proto *p = conn->bgp; @@ -1680,7 +1679,7 @@ bgp_rx_packet(struct bgp_conn *conn, byte *pkt, unsigned len) * bgp_rx_packet(). */ int -bgp_rx(sock *sk, int size) +bgp_rx(sock *sk, uint size) { struct bgp_conn *conn = sk->data; struct bgp_proto *p = conn->bgp; diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c index 195b03ad..d6904343 100644 --- a/proto/ospf/dbdes.c +++ b/proto/ospf/dbdes.c @@ -39,7 +39,7 @@ struct ospf_dbdes3_packet static inline uint -ospf_dbdes_hdrlen(struct ospf_proto *p) +ospf_dbdes_hdrlen(struct ospf_proto *p UNUSED4 UNUSED6) { return ospf_is_v2(p) ? sizeof(struct ospf_dbdes2_packet) : sizeof(struct ospf_dbdes3_packet); diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c index 50cf1407..e00487dc 100644 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@ -222,9 +222,12 @@ ospf_receive_hello(struct ospf_packet *pkt, struct ospf_iface *ifa, rcv_priority = ps->priority; int pxlen = u32_masklen(ntohl(ps->netmask)); + if (pxlen < 0) + DROP("prefix garbled", ntohl(ps->netmask)); + if ((ifa->type != OSPF_IT_VLINK) && (ifa->type != OSPF_IT_PTP) && - (pxlen != ifa->addr->pxlen)) + ((uint) pxlen != ifa->addr->pxlen)) DROP("prefix length mismatch", pxlen); neighbors = ps->neighbors; diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c index 1bbd1372..cb7b186a 100644 --- a/proto/ospf/lsalib.c +++ b/proto/ospf/lsalib.c @@ -463,7 +463,7 @@ lsa_validate_sum3_net(struct ospf_lsa_header *lsa, struct ospf_lsa_sum3_net *bod } static int -lsa_validate_sum3_rt(struct ospf_lsa_header *lsa, struct ospf_lsa_sum3_rt *body) +lsa_validate_sum3_rt(struct ospf_lsa_header *lsa, struct ospf_lsa_sum3_rt *body UNUSED) { if (lsa->length != (HDRLEN + sizeof(struct ospf_lsa_sum3_rt))) return 0; diff --git a/proto/ospf/lsalib.h b/proto/ospf/lsalib.h index ae6af044..638b3525 100644 --- a/proto/ospf/lsalib.h +++ b/proto/ospf/lsalib.h @@ -41,7 +41,7 @@ void lsa_get_type_domain_(u32 itype, struct ospf_iface *ifa, u32 *otype, u32 *do static inline void lsa_get_type_domain(struct ospf_lsa_header *lsa, struct ospf_iface *ifa, u32 *otype, u32 *domain) { lsa_get_type_domain_(lsa->type_raw, ifa, otype, domain); } -static inline u32 lsa_get_etype(struct ospf_lsa_header *h, struct ospf_proto *p) +static inline u32 lsa_get_etype(struct ospf_lsa_header *h, struct ospf_proto *p UNUSED4 UNUSED6) { return ospf_is_v2(p) ? (h->type_raw & LSA_T_V2_MASK) : h->type_raw; } diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c index c6a734ca..157d9628 100644 --- a/proto/ospf/lsupd.c +++ b/proto/ospf/lsupd.c @@ -105,7 +105,7 @@ invalid: static inline void -ospf_lsa_lsrq_down(struct top_hash_entry *req, struct ospf_neighbor *n, struct ospf_neighbor *from) +ospf_lsa_lsrq_down(struct top_hash_entry *req, struct ospf_neighbor *n) { if (req == n->lsrqi) n->lsrqi = SNODE_NEXT(req); @@ -188,7 +188,7 @@ ospf_enqueue_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_if { /* If we already have full queue, we send some packets */ uint sent = ospf_flood_lsupd(p, ifa->flood_queue, ifa->flood_queue_used, ifa->flood_queue_used / 2, ifa); - int i; + uint i; for (i = 0; i < sent; i++) ifa->flood_queue[i]->ret_count--; @@ -275,7 +275,7 @@ ospf_flood_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_neig /* If same or newer, remove LSA from the link state request list */ if (cmp > CMP_OLDER) - ospf_lsa_lsrq_down(req, n, from); + ospf_lsa_lsrq_down(req, n); /* If older or same, skip processing of this neighbor */ if (cmp < CMP_NEWER) diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index 0223ccdf..9fe3c028 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -359,7 +359,7 @@ can_do_adj(struct ospf_neighbor *n) } -static inline u32 neigh_get_id(struct ospf_proto *p, struct ospf_neighbor *n) +static inline u32 neigh_get_id(struct ospf_proto *p UNUSED4 UNUSED6, struct ospf_neighbor *n) { return ospf_is_v2(p) ? ipa_to_u32(n->ip) : n->rid; } static struct ospf_neighbor * diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index a4e525ec..ca30e4e0 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -766,7 +766,7 @@ lsa_get_ipv6_addr(u32 *buf, ip_addr *addr) } static inline u32 * -put_ipv6_prefix(u32 *buf, ip_addr addr, u8 pxlen, u8 pxopts, u16 lh) +put_ipv6_prefix(u32 *buf, ip_addr addr UNUSED4, u8 pxlen UNUSED4, u8 pxopts UNUSED4, u16 lh UNUSED4) { #ifdef IPV6 *buf++ = ((pxlen << 24) | (pxopts << 16) | lh); @@ -840,7 +840,7 @@ static inline int ospf_is_v2(struct ospf_proto *p) static inline int ospf_is_v3(struct ospf_proto *p) { return ! p->ospf2; } */ -static inline int ospf_get_version(struct ospf_proto *p) +static inline int ospf_get_version(struct ospf_proto *p UNUSED4 UNUSED6) { return ospf_is_v2(p) ? 2 : 3; } struct ospf_area *ospf_find_area(struct ospf_proto *p, u32 aid); @@ -897,7 +897,7 @@ void ospf_sh_neigh_info(struct ospf_neighbor *n); /* packet.c */ void ospf_pkt_fill_hdr(struct ospf_iface *ifa, void *buf, u8 h_type); uint ospf_pkt_maxsize(struct ospf_iface *ifa); -int ospf_rx_hook(sock * sk, int size); +int ospf_rx_hook(sock * sk, uint size); // void ospf_tx_hook(sock * sk); void ospf_err_hook(sock * sk, int err); void ospf_verr_hook(sock *sk, int err); @@ -922,7 +922,7 @@ static inline void ospf_send_to_des(struct ospf_iface *ifa) #define SKIP(DSC) do { err_dsc = DSC; goto skip; } while(0) #endif -static inline uint ospf_pkt_hdrlen(struct ospf_proto *p) +static inline uint ospf_pkt_hdrlen(struct ospf_proto *p UNUSED4 UNUSED6) { return ospf_is_v2(p) ? (sizeof(struct ospf_packet) + sizeof(union ospf_auth)) : sizeof(struct ospf_packet); } static inline void * ospf_tx_buffer(struct ospf_iface *ifa) diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index 04f0d47c..aa90aa51 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -124,7 +124,7 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt) /* We assume OSPFv2 in ospf_pkt_checkauth() */ static int -ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf_packet *pkt, int len) +ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf_packet *pkt, uint len) { struct ospf_proto *p = ifa->oa->po; union ospf_auth *auth = (void *) (pkt + 1); @@ -214,7 +214,7 @@ drop: * non generic functions. */ int -ospf_rx_hook(sock *sk, int len) +ospf_rx_hook(sock *sk, uint len) { /* We want just packets from sk->iface. Unfortunately, on BSD we cannot filter out other packets at kernel level and we receive all packets on all sockets */ diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index cdf8012a..8b3feda9 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -1049,7 +1049,7 @@ check_sum_rt_lsa(struct ospf_proto *p, ort *nf) } static inline int -decide_nssa_lsa(struct ospf_proto *p, ort *nf, struct ospf_lsa_ext_local *rt) +decide_nssa_lsa(struct ospf_proto *p UNUSED4 UNUSED6, ort *nf, struct ospf_lsa_ext_local *rt) { struct ospf_area *oa = nf->n.oa; struct top_hash_entry *en = nf->n.en; diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 7558d4a0..341eff87 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -515,7 +515,7 @@ ospf_update_lsadb(struct ospf_proto *p) static inline u32 -ort_to_lsaid(struct ospf_proto *p, ort *nf) +ort_to_lsaid(struct ospf_proto *p UNUSED4 UNUSED6, ort *nf) { /* * In OSPFv2, We have to map IP prefixes to u32 in such manner that resulting @@ -607,7 +607,7 @@ lsab_offset(struct ospf_proto *p, uint offset) return ((byte *) p->lsab) + offset; } -static inline void * +static inline void * UNUSED lsab_end(struct ospf_proto *p) { return ((byte *) p->lsab) + p->lsab_used; @@ -1545,7 +1545,7 @@ static void add_link_lsa(struct ospf_proto *p, struct ospf_lsa_link *ll, int offset, int *pxc) { u32 *pxb = ll->rest; - int j; + uint j; for (j = 0; j < ll->pxcount; pxb = prefix_advance(pxb), j++) { @@ -1748,7 +1748,7 @@ ospf_top_hash(struct top_graph *f, u32 domain, u32 lsaid, u32 rtrid, u32 type) * and request lists of OSPF neighbors. */ struct top_graph * -ospf_top_new(struct ospf_proto *p, pool *pool) +ospf_top_new(struct ospf_proto *p UNUSED4 UNUSED6, pool *pool) { struct top_graph *f; diff --git a/proto/radv/packets.c b/proto/radv/packets.c index 3862af8d..4bf960c3 100644 --- a/proto/radv/packets.c +++ b/proto/radv/packets.c @@ -157,12 +157,12 @@ radv_process_domain(struct radv_dnssl_config *cf) char *dom = cf->domain; char *dom_end = dom; /* Just to */ u8 *dlen_save = &cf->dlen_first; - int len; + uint len; while (dom_end) { dom_end = strchr(dom, '.'); - len = dom_end ? (dom_end - dom) : strlen(dom); + len = dom_end ? (uint)(dom_end - dom) : strlen(dom); if (len < 1 || len > 63) return -1; @@ -348,7 +348,7 @@ radv_send_ra(struct radv_iface *ifa, int shutdown) static int -radv_rx_hook(sock *sk, int size) +radv_rx_hook(sock *sk, uint size) { struct radv_iface *ifa = sk->data; struct proto_radv *ra = ifa->ra; diff --git a/proto/radv/radv.c b/proto/radv/radv.c index 6370e006..5c52217d 100644 --- a/proto/radv/radv.c +++ b/proto/radv/radv.c @@ -240,7 +240,7 @@ radv_if_notify(struct proto *p, unsigned flags, struct iface *iface) } static void -radv_ifa_notify(struct proto *p, unsigned flags, struct ifa *a) +radv_ifa_notify(struct proto *p, unsigned flags UNUSED, struct ifa *a) { struct proto_radv *ra = (struct proto_radv *) p; diff --git a/proto/radv/radv.h b/proto/radv/radv.h index 48ba9c1a..e2bf07ba 100644 --- a/proto/radv/radv.h +++ b/proto/radv/radv.h @@ -84,7 +84,7 @@ struct radv_prefix_config { node n; ip_addr prefix; - int pxlen; + uint pxlen; u8 skip; /* Do not include this prefix to RA */ u8 onlink; /* Standard options from RFC 4261 */ diff --git a/proto/rip/packets.c b/proto/rip/packets.c index 9f10fd67..e026eaea 100644 --- a/proto/rip/packets.c +++ b/proto/rip/packets.c @@ -108,7 +108,7 @@ static inline uint rip_pkt_hdrlen(struct rip_iface *ifa) { return sizeof(struct rip_packet) + (ifa->cf->auth_type ? RIP_BLOCK_LENGTH : 0); } static inline void -rip_put_block(struct rip_proto *p, byte *pos, struct rip_block *rte) +rip_put_block(struct rip_proto *p UNUSED4 UNUSED6, byte *pos, struct rip_block *rte) { if (rip_is_v2(p)) { @@ -131,7 +131,7 @@ rip_put_block(struct rip_proto *p, byte *pos, struct rip_block *rte) } static inline void -rip_put_next_hop(struct rip_proto *p, byte *pos, struct rip_block *rte) +rip_put_next_hop(struct rip_proto *p UNUSED, byte *pos, struct rip_block *rte UNUSED4) { struct rip_block_ng *block = (void *) pos; block->prefix = ip6_hton(ipa_to_ip6(rte->next_hop)); @@ -141,7 +141,7 @@ rip_put_next_hop(struct rip_proto *p, byte *pos, struct rip_block *rte) } static inline int -rip_get_block(struct rip_proto *p, byte *pos, struct rip_block *rte) +rip_get_block(struct rip_proto *p UNUSED4 UNUSED6, byte *pos, struct rip_block *rte) { if (rip_is_v2(p)) { @@ -630,7 +630,7 @@ rip_receive_response(struct rip_proto *p, struct rip_iface *ifa, struct rip_pack } static int -rip_rx_hook(sock *sk, int len) +rip_rx_hook(sock *sk, uint len) { struct rip_iface *ifa = sk->data; struct rip_proto *p = ifa->rip; diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 36527253..37cfa9ac 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -1027,7 +1027,7 @@ rip_prepare_attrs(struct linpool *pool, ea_list *next, u8 metric, u16 tag) } static int -rip_import_control(struct proto *P, struct rte **rt, struct ea_list **attrs, struct linpool *pool) +rip_import_control(struct proto *P UNUSED, struct rte **rt, struct ea_list **attrs, struct linpool *pool) { /* Prepare attributes with initial values */ if ((*rt)->attrs->source != RTS_RIP) @@ -1144,7 +1144,7 @@ rip_reconfigure(struct proto *P, struct proto_config *c) } static void -rip_get_route_info(rte *rte, byte *buf, ea_list *attrs) +rip_get_route_info(rte *rte, byte *buf, ea_list *attrs UNUSED) { buf += bsprintf(buf, " (%d/%d)", rte->pref, rte->u.rip.metric); diff --git a/proto/static/static.c b/proto/static/static.c index d54302a8..0c088cd7 100644 --- a/proto/static/static.c +++ b/proto/static/static.c @@ -250,7 +250,7 @@ static_add(struct proto *p, struct static_config *cf, struct static_route *r) } static void -static_rte_cleanup(struct proto *p, struct static_route *r) +static_rte_cleanup(struct proto *p UNUSED, struct static_route *r) { struct static_route *r2; @@ -435,7 +435,7 @@ static_if_notify(struct proto *p, unsigned flags, struct iface *i) } int -static_rte_mergable(rte *pri, rte *sec) +static_rte_mergable(rte *pri UNUSED, rte *sec UNUSED) { return 1; } |