]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Build: switch on -Wextra, get rid of most of the warnings
authorJan Moskyto Matejka <mq@ucw.cz>
Fri, 14 Oct 2016 13:37:04 +0000 (15:37 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 1 Nov 2016 13:52:54 +0000 (14:52 +0100)
There are several unresolved -Wmissing-field-initializers on older
versions of GCC than 5.1, all of them false positive.

50 files changed:
client/birdcl.c
client/util.c
conf/Makefile
conf/conf.c
configure.in
filter/filter.c
lib/birdlib.h
lib/hash.h
lib/socket.h
nest/a-path.c
nest/bfd.h
nest/iface.c
nest/locks.c
nest/route.h
nest/rt-attr.c
nest/rt-table.c
proto/babel/babel.c
proto/babel/babel.h
proto/babel/packets.c
proto/bfd/bfd.c
proto/bfd/packets.c
proto/bgp/attrs.c
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/packets.c
proto/ospf/dbdes.c
proto/ospf/hello.c
proto/ospf/lsalib.c
proto/ospf/lsalib.h
proto/ospf/lsupd.c
proto/ospf/neighbor.c
proto/ospf/ospf.h
proto/ospf/packet.c
proto/ospf/rt.c
proto/ospf/topology.c
proto/radv/packets.c
proto/radv/radv.c
proto/radv/radv.h
proto/rip/packets.c
proto/rip/rip.c
proto/static/static.c
sysdep/bsd/krt-sock.c
sysdep/bsd/krt-sys.h
sysdep/bsd/sysio.h
sysdep/linux/krt-sys.h
sysdep/linux/netlink.c
sysdep/unix/io.c
sysdep/unix/krt.c
sysdep/unix/main.c
sysdep/unix/unix.h

index 7b567a9ff01f1051e00bf8a4c73f28d5032f96d5..4508185ca5ffc8b14f2cb7b50a9e401e3ede0ba0 100644 (file)
@@ -125,7 +125,7 @@ more_end(void)
 }
 
 static void
-sig_handler(int signal)
+sig_handler(int signal UNUSED)
 {
   cleanup();
   exit(0);
index 2d6c074d63140422c2aa93ae8abebe4d537e06b1..1d83e518dc083ad65fe2facd315dad7d033ba1b8 100644 (file)
@@ -24,7 +24,7 @@ vlog(const char *msg, va_list args)
   int n = vsnprintf(buf, sizeof(buf), msg, args);
   if (n < 0)
     snprintf(buf, sizeof(buf), "???");
-  if (n >= sizeof(buf))
+  else if (n >= (int) sizeof(buf))
     snprintf(buf + sizeof(buf) - 100, 100, " ... <too long>");
   fputs(buf, stderr);
   fputc('\n', stderr);
index 5d729a421210557237111abf669f0175976d61c6..cd78c82128775251388d2cab1a5988968588f161 100644 (file)
@@ -29,3 +29,5 @@ cf-lex.c: cf-lex.l
        $(FLEX) $(FLEX_DEBUG) -s -B -8 -ocf-lex.c -Pcf_ cf-lex.l
 
 depend: keywords.h commands.h cf-parse.tab.c cf-lex.c
+
+cf-lex.o: CFLAGS+=-Wno-sign-compare -Wno-unused-function
index efaeedeb95ed683479e17c561e516e10174a65e5..029814c60a400dfdc11e7bcd0943688b9badf21e 100644 (file)
@@ -450,7 +450,7 @@ config_undo(void)
 extern void cmd_reconfig_undo_notify(void);
 
 static void
-config_timeout(struct timer *t)
+config_timeout(struct timer *t UNUSED)
 {
   log(L_INFO "Config timeout expired, starting undo");
   cmd_reconfig_undo_notify();
index 16a0b4146241806534c3735f19e630c86b611d5e..57fa00797295da49bb3d009ab66d35d75179a986 100644 (file)
@@ -111,11 +111,13 @@ fi
 
 if test "$bird_cflags_default" = yes ; then
        BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
+       BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
        BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
        BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
 
-       CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wno-parentheses"
+       CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
        BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
+       BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
        BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
        BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
 fi
index 510303a766d404695913efb494728aa6519438dc..85a0625860896637bd6f926aa20dd19e00d854f2 100644 (file)
@@ -380,7 +380,7 @@ clist_filter(struct linpool *pool, struct adata *list, struct f_val set, int pos
       *k++ = v.val.i;
   }
 
-  int nl = (k - tmp) * 4;
+  uint nl = (k - tmp) * sizeof(u32);
   if (nl == list->length)
     return list;
 
@@ -414,7 +414,7 @@ eclist_filter(struct linpool *pool, struct adata *list, struct f_val set, int po
     }
   }
 
-  int nl = (k - tmp) * 4;
+  uint nl = (k - tmp) * sizeof(u32);
   if (nl == list->length)
     return list;
 
@@ -446,7 +446,7 @@ lclist_filter(struct linpool *pool, struct adata *list, struct f_val set, int po
       k = lc_copy(k, l+i);
   }
 
-  int nl = (k - tmp) * 4;
+  uint nl = (k - tmp) * sizeof(u32);
   if (nl == list->length)
     return list;
 
index 904544cb1315db25fecd4c19e1689d6e1a3ce8f2..37337078d4bb99fb909421fb16e876ab5cecbeef 100644 (file)
 #define UNUSED __attribute__((unused))
 #define PACKED __attribute__((packed))
 
+#ifdef IPV6
+#define UNUSED4
+#define UNUSED6 UNUSED
+#else
+#define UNUSED4 UNUSED
+#define UNUSED6
+#endif
 
 /* Microsecond time */
 
index a73f647abb4c4cac2bbba1ef931f7813f60e4829..fc5fea14ba6b225fc9c83ce9689d04a329b0c519 100644 (file)
@@ -2,7 +2,7 @@
 
 #define HASH(type)             struct { type **data; uint count, order; }
 #define HASH_TYPE(v)           typeof(** (v).data)
-#define HASH_SIZE(v)           (1 << (v).order)
+#define HASH_SIZE(v)           (1U << (v).order)
 
 #define HASH_EQ(v,id,k1,k2...) (id##_EQ(k1, k2))
 #define HASH_FN(v,id,key...)   ((u32) (id##_FN(key)) >> (32 - (v).order))
 
 #define HASH_MAY_RESIZE_DOWN_(v,pool,rehash_fn,args)                   \
   ({                                                                    \
-    int _o = (v).order;                                                        \
-    while (((v).count < ((1 << _o) REHASH_LO_MARK(args))) &&           \
+    uint _o = (v).order;                                                       \
+    while (((v).count < ((1U << _o) REHASH_LO_MARK(args))) &&          \
           (_o > (REHASH_LO_BOUND(args))))                              \
       _o -= (REHASH_LO_STEP(args));                                    \
     if (_o < (v).order)                                                        \
-      rehash_fn(&(v), pool, _o - (int) (v).order);                     \
+      rehash_fn(&(v), pool, _o - (v).order);                           \
   })
 
 
index 6babfa7bc5ecc00e56cfc76c6b3e4ec06252e4dc..2da5212756a6a9e497faad259ac6af4e1016b7b7 100644 (file)
@@ -30,7 +30,7 @@ typedef struct birdsock {
   byte *rbuf, *rpos;                   /* NULL=allocate automatically */
   uint fast_rx;                                /* RX has higher priority in event loop */
   uint rbsize;
-  int (*rx_hook)(struct birdsock *, int size); /* NULL=receiving turned off, returns 1 to clear rx buffer */
+  int (*rx_hook)(struct birdsock *, uint size); /* NULL=receiving turned off, returns 1 to clear rx buffer */
 
   byte *tbuf, *tpos;                   /* NULL=allocate automatically */
   byte *ttx;                           /* Internal */
index e1031b7bde06a6d8cc43edf235c7ad8b598e8ca6..b453f702099e8dce770c6e1b890a74b077152d77 100644 (file)
@@ -370,7 +370,7 @@ as_path_filter(struct linpool *pool, struct adata *path, struct f_tree *set, u32
        }
   }
 
-  int nl = d - buf;
+  uint nl = d - buf;
   if (nl == path->length)
     return path;
 
index f1e95cb2346609eb276fa0f5e475448b177debda..b0ebe31da84f89232ef5e4b9af99c117151147d3 100644 (file)
@@ -42,7 +42,7 @@ struct bfd_request {
 
 struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, void (*hook)(struct bfd_request *), void *data);
 
-static inline void cf_check_bfd(int use) { }
+static inline void cf_check_bfd(int use UNUSED) { }
 
 #else
 
index 4d73c2a4a1792dcea87ca9c10c90cb66dc9df020..a23cdf4fc8a67f330aa83fe794a6364f4dd23f79 100644 (file)
@@ -584,7 +584,7 @@ ifa_delete(struct ifa *a)
 }
 
 u32
-if_choose_router_id(struct iface_patt *mask, u32 old_id)
+if_choose_router_id(struct iface_patt *mask UNUSED6, u32 old_id UNUSED6)
 {
 #ifndef IPV6
   struct iface *i;
index ad2af4938959d7219958562825fa7ea112e96321..84b8b0aefe2f938c564f07bf3e77eaabe29432eb 100644 (file)
@@ -100,7 +100,8 @@ static struct resclass olock_class = {
   sizeof(struct object_lock),
   olock_free,
   olock_dump,
-  NULL
+  NULL,
+  NULL,
 };
 
 /**
index 07320566d6d912c1e363a04a8cdab26f4e748884..383f4def09420c1539bb85ad511fdc0b5cc8fa7c 100644 (file)
@@ -274,7 +274,6 @@ rte *rte_find(net *net, struct rte_src *src);
 rte *rte_get_temp(struct rta *);
 void rte_update2(struct announce_hook *ah, net *net, rte *new, struct rte_src *src);
 static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_ahook, net, new, p->main_source); }
-void rte_discard(rtable *tab, rte *old);
 int rt_examine(rtable *t, ip_addr prefix, int pxlen, struct proto *p, struct filter *filter);
 rte *rt_export_merged(struct announce_hook *ah, net *net, rte **rt_free, struct ea_list **tmpa, linpool *pool, int silent);
 void rt_refresh_begin(rtable *t, struct announce_hook *ah);
index 9aeca8465f5e67b8afcaeff36afcaddbf8cfdd1f..edf27d4457e30d4d1efd9da02d1f9feee12f74bb 100644 (file)
@@ -103,7 +103,7 @@ static inline int u32_cto(uint x) { return ffs(~x) - 1; }
 static inline u32
 rte_src_alloc_id(void)
 {
-  int i, j;
+  uint i, j;
   for (i = src_id_pos; i < src_id_size; i++)
     if (src_ids[i] != 0xffffffff)
       goto found;
@@ -785,7 +785,7 @@ static inline void
 opaque_format(struct adata *ad, byte *buf, uint size)
 {
   byte *bound = buf + size - 10;
-  int i;
+  uint i;
 
   for(i = 0; i < ad->length; i++)
     {
index 00476069a210d2df140c5ab8e2e756ebe1fe630e..c6e48c38016eb18ed2bceae64b97e0dae2835a8b 100644 (file)
@@ -1282,8 +1282,8 @@ rte_announce_i(rtable *tab, unsigned type, net *net, rte *new, rte *old,
   rte_update_unlock();
 }
 
-void
-rte_discard(rtable *t, rte *old)       /* Non-filtered route deletion, used during garbage collection */
+static inline void
+rte_discard(rte *old)  /* Non-filtered route deletion, used during garbage collection */
 {
   rte_update_lock();
   rte_recalculate(old->sender, old->net, NULL, old->attrs->src);
@@ -1606,7 +1606,7 @@ again:
                return 0;
              }
 
-           rte_discard(tab, e);
+           rte_discard(e);
            (*limit)--;
 
            goto rescan;
@@ -1712,7 +1712,7 @@ rta_apply_hostentry(rta *a, struct hostentry *he)
 }
 
 static inline rte *
-rt_next_hop_update_rte(rtable *tab, rte *old)
+rt_next_hop_update_rte(rtable *tab UNUSED, rte *old)
 {
   rta a;
   memcpy(&a, old->attrs, sizeof(rta));
@@ -2104,11 +2104,11 @@ hc_remove(struct hostcache *hc, struct hostentry *he)
 static void
 hc_alloc_table(struct hostcache *hc, unsigned order)
 {
-  unsigned hsize = 1 << order;
+  uint hsize = 1 << order;
   hc->hash_order = order;
   hc->hash_shift = 16 - order;
-  hc->hash_max = (order >= HC_HI_ORDER) ? ~0 : (hsize HC_HI_MARK);
-  hc->hash_min = (order <= HC_LO_ORDER) ?  0 : (hsize HC_LO_MARK);
+  hc->hash_max = (order >= HC_HI_ORDER) ? ~0U : (hsize HC_HI_MARK);
+  hc->hash_min = (order <= HC_LO_ORDER) ?  0U : (hsize HC_LO_MARK);
 
   hc->hash_table = mb_allocz(rt_table_pool, hsize * sizeof(struct hostentry *));
 }
@@ -2116,10 +2116,10 @@ hc_alloc_table(struct hostcache *hc, unsigned order)
 static void
 hc_resize(struct hostcache *hc, unsigned new_order)
 {
-  unsigned old_size = 1 << hc->hash_order;
   struct hostentry **old_table = hc->hash_table;
   struct hostentry *he, *hen;
-  int i;
+  uint old_size = 1 << hc->hash_order;
+  uint i;
 
   hc_alloc_table(hc, new_order);
   for (i = 0; i < old_size; i++)
index 9d73a2642cc5f77896108d29b9446430e51089aa..38be69090f5c52de9d4efb79da769b6430b794bb 100644 (file)
@@ -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;
index 481c88a7042ba9031c03f2c0f77ddcbf28b27c57..6a95d82f053eda8961127d20c213d9f55b696e5d 100644 (file)
@@ -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;
index 65dd685312c83fff35675df376077e56de0a5158..08054832839d4444fcc3d157426fd368ab03fcd9 100644 (file)
@@ -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 *stateint 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 *stateint 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 *stateint 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;
index 5de2f5563dcde08e699893da2a4f115b1ae49531..e7be6a8adae16c549cf4679e6ddfb2ffd18af6cc 100644 (file)
@@ -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;
index cb40bcdadfb4193677bde1e28381f9a570a101e5..deb501fc9fefac1988bec74863d479fccf884b0b 100644 (file)
@@ -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;
index 6fe34e56ffcd3e7b35b4bacde3738ec7e29ae959..0309c1f774e16986a10d16c382f881f5f4da814e 100644 (file)
@@ -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;
index 2014525e49de1ff17d3b4c743d62ea793364e5f0..8ef4b990108b9beacddbfb0d4f21a4a43a7f7692 100644 (file)
@@ -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;
index a865b99d73c497fb122964956393fd45a45318f4..b4067f3a02aa517169fc94ff90c481645a603dc6 100644 (file)
@@ -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);
 
index 0cf38edf41a44f68d6229eccdca19e30943d0c3f..3e816839a7d9fddd7673fb594a3533a8226fc188 100644 (file)
@@ -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;
index 195b03adefdcad642beaccc4bae1fbff00594dd6..d6904343c7b61e387783eab0653f29143012d159 100644 (file)
@@ -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);
index 50cf1407e88126490883c9fdb6e5b6a7d10c219d..e00487dc6d40ce39e5f28646d45d6610a7c52b98 100644 (file)
@@ -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;
index 1bbd13724490aae399bc1d44da8edd2baef005a8..cb7b186a53139a2cfa2a1ee776fc357a2ead9450 100644 (file)
@@ -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;
index ae6af044141f40cf178659313a86fa4cfda30b4d..638b35259f296406a60aea17510f93548e8c7af7 100644 (file)
@@ -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; }
 
 
index c6a734ca48a2503f4b274bca6ffcf32fc1f76ace..157d96281862eccbaa6d0e1dfe10864a2e4ec6ee 100644 (file)
@@ -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)
index 0223ccdf211b3f2b39fb1bd7352fc2bbf7f1a96c..9fe3c02889cdd8e1c22796d34cc93870d4362efe 100644 (file)
@@ -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 *
index a4e525ec23c5b3649baf5daf7cbd96dfdd7fdc19..ca30e4e0c8c08cc580e37680d9031d8c98ae1d85 100644 (file)
@@ -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)
index 04f0d47c3421b77d0bd3f89285b682d9ed5a6b2b..aa90aa51e88fb4fb20f8fd90636b3f03a9a1df63 100644 (file)
@@ -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 */
index cdf8012a56fcf700fbe11b34800b698fab9d2ada..8b3feda90e50de8f2a60d19072f6abbdb7920ae5 100644 (file)
@@ -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;
index 7558d4a00070910d84f5091dcd2a2b41b10fb700..341eff87eb5a6fed39b2f99bd37e90129deaeb72 100644 (file)
@@ -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;
 
index 3862af8d4ad8c5d4d1ed18a3ea6f48f97c664417..4bf960c317aa160ca3ca4a9463904454eb0b44e4 100644 (file)
@@ -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;
index 6370e006f29f20bc5178a8a86f636b462e37b966..5c52217d2d0af0be7fbd0179e48074ec80d24ed0 100644 (file)
@@ -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;
 
index 48ba9c1a308df119b3953fd9a745faa5c85dd4ec..e2bf07bace29b4455b04f5472eb6441dc8abec70 100644 (file)
@@ -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 */
index 9f10fd675e34b4e30865ac4b5fa23e6321bd731e..e026eaea6fc87cf8b8ac698c5b9c6796c7ffb49f 100644 (file)
@@ -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;
index 365272538c8169329e75364132a91137c5fcc770..37cfa9ac6ada8608055649a9363ed504e0f8af23 100644 (file)
@@ -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);
 
index d54302a8908165362e6048d55c009d325ae305ea..0c088cd7fdf95068bd6db1c559bec875c8e0327b 100644 (file)
@@ -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;
 }
index f2ae81c33162c2e67bd6969bb9092e033357eeeb..9c9df51de527ba0191ff88ebeaee993fa99618e7 100644 (file)
@@ -898,7 +898,7 @@ kif_do_scan(struct kif_proto *p)
 /* Kernel sockets */
 
 static int
-krt_sock_hook(sock *sk, int size UNUSED)
+krt_sock_hook(sock *sk, uint size UNUSED)
 {
   struct ks_msg msg;
   int l = read(sk->fd, (char *)&msg, sizeof(msg));
@@ -918,7 +918,7 @@ krt_sock_err_hook(sock *sk, int e UNUSED)
 }
 
 static sock *
-krt_sock_open(pool *pool, void *data, int table_id)
+krt_sock_open(pool *pool, void *data, int table_id UNUSED)
 {
   sock *sk;
   int fd;
@@ -1074,7 +1074,7 @@ kif_sys_shutdown(struct kif_proto *p)
 
 
 struct ifa *
-kif_get_primary_ip(struct iface *i)
+kif_get_primary_ip(struct iface *i UNUSED6)
 {
 #ifndef IPV6
   static int fd = -1;
index a63f8caf9efe02f6757bac007985b16f8d3f650d..353ffcec56c601ef9757776d97b71e1b125450da 100644 (file)
@@ -45,7 +45,7 @@ struct krt_state {
 static inline void krt_sys_io_init(void) { }
 static inline void krt_sys_init(struct krt_proto *p UNUSED) { }
 
-static inline int krt_sys_get_attr(eattr *a UNUSED, byte *buf UNUSED, int buflen UNUSED) { }
+static inline int krt_sys_get_attr(eattr *a UNUSED, byte *buf UNUSED, int buflen UNUSED) { return 0; }
 
 
 #endif
index 6c20733fda5ce5e1017ce4bd36cb28e352cb9123..8d87a3c36d158ec44ae362e9b32b98efd3d71365 100644 (file)
@@ -28,7 +28,9 @@
 #endif
 
 
+#ifndef SA_LEN
 #define SA_LEN(x) (x).sa.sa_len
+#endif
 
 
 /*
@@ -133,12 +135,12 @@ sk_process_cmsg4_ttl(sock *s, struct cmsghdr *cm)
     s->rcv_ttl = * (byte *) CMSG_DATA(cm);
 }
 
+#ifdef IP_SENDSRCADDR
 static inline void
 sk_prepare_cmsgs4(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
 {
   /* Unfortunately, IP_SENDSRCADDR does not work for raw IP sockets on BSD kernels */
 
-#ifdef IP_SENDSRCADDR
   struct cmsghdr *cm;
   struct in_addr *sa;
   int controllen = 0;
@@ -156,10 +158,13 @@ sk_prepare_cmsgs4(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
   *sa = ipa_to_in4(s->saddr);
 
   msg->msg_controllen = controllen;
-#endif
 }
+#else
+static inline void
+sk_prepare_cmsgs4(sock *s UNUSED, struct msghdr *msg UNUSED, void *cbuf UNUSED, size_t cbuflen UNUSED) { }
+#endif
 
-static void
+static void UNUSED
 sk_prepare_ip_header(sock *s, void *hdr, int dlen)
 {
   struct ip *ip = hdr;
@@ -200,7 +205,7 @@ sk_prepare_ip_header(sock *s, void *hdr, int dlen)
 #endif
 
 int
-sk_set_md5_auth(sock *s, ip_addr local, ip_addr remote, struct iface *ifa, char *passwd, int setkey UNUSED)
+sk_set_md5_auth(sock *s, ip_addr local UNUSED, ip_addr remote UNUSED, struct iface *ifa UNUSED, char *passwd, int setkey UNUSED)
 {
 #ifdef USE_MD5SIG_SETKEY
   if (setkey)
@@ -235,20 +240,20 @@ sk_set_min_ttl4(sock *s, int ttl)
 }
 
 static inline int
-sk_set_min_ttl6(sock *s, int ttl)
+sk_set_min_ttl6(sock *s, int ttl UNUSED)
 {
   ERR_MSG("Kernel does not support IPv6 TTL security");
 }
 
 static inline int
-sk_disable_mtu_disc4(sock *s)
+sk_disable_mtu_disc4(sock *s UNUSED)
 {
   /* TODO: Set IP_DONTFRAG to 0 ? */
   return 0;
 }
 
 static inline int
-sk_disable_mtu_disc6(sock *s)
+sk_disable_mtu_disc6(sock *s UNUSED)
 {
   /* TODO: Set IPV6_DONTFRAG to 0 ? */
   return 0;
index 6d6586d10f0295843b9cbcca970e99eaa6f96ef5..76ae29b716e550b79a82081a524cf7413efbeb4b 100644 (file)
@@ -27,7 +27,7 @@ static inline void kif_sys_postconfig(struct kif_config *c UNUSED) { }
 static inline void kif_sys_init_config(struct kif_config *c UNUSED) { }
 static inline void kif_sys_copy_config(struct kif_config *d UNUSED, struct kif_config *s UNUSED) { }
 
-static inline struct ifa * kif_get_primary_ip(struct iface *i) { return NULL; }
+static inline struct ifa * kif_get_primary_ip(struct iface *i UNUSED) { return NULL; }
 
 
 /* Kernel routes */
index 79dd1405081b91ae69c401f46fb8d8d9748913be..368e0ef9d9881666a78e933f8df2d5bc1bef01d6 100644 (file)
@@ -487,7 +487,7 @@ nl_parse_multipath(struct krt_proto *p, struct rtattr *ra)
   struct rtattr *a[BIRD_RTA_MAX];
   struct rtnexthop *nh = RTA_DATA(ra);
   struct mpnh *rv, *first, **last;
-  int len = RTA_PAYLOAD(ra);
+  unsigned len = RTA_PAYLOAD(ra);
 
   first = NULL;
   last = &first;
@@ -1473,7 +1473,7 @@ nl_async_msg(struct nlmsghdr *h)
 }
 
 static int
-nl_async_hook(sock *sk, int size UNUSED)
+nl_async_hook(sock *sk, uint size UNUSED)
 {
   struct iovec iov = { nl_async_rx_buffer, NL_RX_SIZE };
   struct sockaddr_nl sa;
index 3ceadd982f619757aec0aa4c0b7608299cc638e6..873b580575b6b435f3ac96aa8ef23ca0edf714dd 100644 (file)
@@ -507,11 +507,11 @@ tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t)
  *     Sockaddr helper functions
  */
 
-static inline int sockaddr_length(int af)
+static inline int UNUSED sockaddr_length(int af)
 { return (af == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); }
 
 static inline void
-sockaddr_fill4(struct sockaddr_in *sa, ip_addr a, struct iface *ifa, uint port)
+sockaddr_fill4(struct sockaddr_in *sa, ip_addr a, uint port)
 {
   memset(sa, 0, sizeof(struct sockaddr_in));
 #ifdef HAVE_SIN_LEN
@@ -542,7 +542,7 @@ void
 sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port)
 {
   if (af == AF_INET)
-    sockaddr_fill4((struct sockaddr_in *) sa, a, ifa, port);
+    sockaddr_fill4((struct sockaddr_in *) sa, a, port);
   else if (af == AF_INET6)
     sockaddr_fill6((struct sockaddr_in6 *) sa, a, ifa, port);
   else
@@ -550,7 +550,7 @@ sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port)
 }
 
 static inline void
-sockaddr_read4(struct sockaddr_in *sa, ip_addr *a, struct iface **ifa, uint *port)
+sockaddr_read4(struct sockaddr_in *sa, ip_addr *a, uint *port)
 {
   *port = ntohs(sa->sin_port);
   *a = ipa_from_in4(sa->sin_addr);
@@ -573,7 +573,7 @@ sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port)
     goto fail;
 
   if (af == AF_INET)
-    sockaddr_read4((struct sockaddr_in *) sa, a, ifa, port);
+    sockaddr_read4((struct sockaddr_in *) sa, a, port);
   else if (af == AF_INET6)
     sockaddr_read6((struct sockaddr_in6 *) sa, a, ifa, port);
   else
@@ -770,7 +770,7 @@ sk_set_tos6(sock *s, int tos)
 }
 
 static inline int
-sk_set_high_port(sock *s)
+sk_set_high_port(sock *s UNUSED)
 {
   /* Port range setting is optional, ignore it if not supported */
 
index ef98cb3a175ae7a616d4262034f9445415f603f0..07a55c0d29f15e5a7edb2324994cdc2e9ac021bb 100644 (file)
@@ -909,7 +909,7 @@ krt_scan_timer_start(struct krt_proto *p)
 }
 
 static void
-krt_scan_timer_stop(struct krt_proto *p)
+krt_scan_timer_stop(struct krt_proto *p UNUSED)
 {
   krt_scan_count--;
 
@@ -998,7 +998,7 @@ krt_store_tmp_attrs(rte *rt, struct ea_list *attrs)
 }
 
 static int
-krt_import_control(struct proto *P, rte **new, ea_list **attrs, struct linpool *pool)
+krt_import_control(struct proto *P, rte **new, ea_list **attrs UNUSED, struct linpool *pool UNUSED)
 {
   struct krt_proto *p = (struct krt_proto *) P;
   rte *e = *new;
index a79899205627d87058c8afb2debff8ca767e20c4..35bc3fd1ecd6fb956092aeb9096e069770aae95e 100644 (file)
@@ -73,7 +73,7 @@ async_dump(void)
 #else
 
 static inline void
-drop_uid(uid_t uid)
+drop_uid(uid_t uid UNUSED)
 {
   die("Cannot change user on this platform");
 }
@@ -419,7 +419,7 @@ cli_get_command(cli *c)
 }
 
 static int
-cli_rx(sock *s, int size UNUSED)
+cli_rx(sock *s, uint size UNUSED)
 {
   cli_kick(s->data);
   return 0;
@@ -439,7 +439,7 @@ cli_err(sock *s, int err)
 }
 
 static int
-cli_connect(sock *s, int size UNUSED)
+cli_connect(sock *s, uint size UNUSED)
 {
   cli *c;
 
index 4e0ff84110e17cb7b87ea95fef8b44dfb5ba8f69..3ef2e3ef37a2827761adb9a01da1a7f81c75fc76 100644 (file)
@@ -63,16 +63,16 @@ typedef struct sockaddr_bird {
 #endif
 
 
-static inline ip_addr ipa_from_in4(struct in_addr a)
+static inline ip_addr ipa_from_in4(struct in_addr a UNUSED6)
 { return ipa_from_u32(ntohl(a.s_addr)); }
 
-static inline ip_addr ipa_from_in6(struct in6_addr a)
+static inline ip_addr ipa_from_in6(struct in6_addr a UNUSED4)
 { return ipa_build6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
 
-static inline ip_addr ipa_from_sa4(sockaddr *sa)
+static inline ip_addr ipa_from_sa4(sockaddr *sa UNUSED6)
 { return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); }
 
-static inline ip_addr ipa_from_sa6(sockaddr *sa)
+static inline ip_addr ipa_from_sa6(sockaddr *sa UNUSED4)
 { return ipa_from_in6(((struct sockaddr_in6 *) sa)->sin6_addr); }
 
 static inline struct in_addr ipa_to_in4(ip_addr a)
@@ -83,7 +83,7 @@ static inline struct in6_addr ipa_to_in6(ip_addr a)
 { return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; }
 #else
 /* Temporary dummy */
-static inline struct in6_addr ipa_to_in6(ip_addr a)
+static inline struct in6_addr ipa_to_in6(ip_addr a UNUSED)
 { return (struct in6_addr) { .s6_addr32 = { 0, 0, 0, 0 } }; }
 #endif