summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:04:26 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:04:26 +0200
commit24873f0c06e6196a105f648e8fe29d19dcddd1de (patch)
treef0ad6ae52390a9ed3b63c6fe228da30f5cf92d7b
parentbgpd: bgpd-no-as.patch (diff)
downloadfrr-24873f0c06e6196a105f648e8fe29d19dcddd1de.tar.xz
frr-24873f0c06e6196a105f648e8fe29d19dcddd1de.zip
lib: lib-warnings.patch
Remove compile warnings for the lib directory Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by:
-rw-r--r--lib/command.c4
-rw-r--r--lib/distribute.c13
-rw-r--r--lib/hash.c2
-rw-r--r--lib/hash.h2
-rw-r--r--lib/if.c6
-rw-r--r--lib/if_rmap.c14
-rw-r--r--lib/jhash.c4
-rw-r--r--lib/jhash.h2
-rw-r--r--lib/libospf.h4
-rw-r--r--lib/md5.c4
-rw-r--r--lib/routemap.c76
-rw-r--r--lib/routemap.h2
-rw-r--r--lib/table.c3
-rw-r--r--lib/thread.c2
-rw-r--r--lib/vty.c5
-rw-r--r--lib/vty.h2
-rw-r--r--lib/workqueue.c12
-rw-r--r--lib/zclient.c2
18 files changed, 80 insertions, 79 deletions
diff --git a/lib/command.c b/lib/command.c
index 065d2fda7..b6dd8bacf 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1412,7 +1412,7 @@ cmd_matcher_read_keywords(struct cmd_matcher *matcher,
const char *word;
int keyword_argc;
const char **keyword_argv;
- enum matcher_rv rv;
+ enum matcher_rv rv = MATCHER_OK;
keyword_mask = 0;
while (1)
@@ -1643,7 +1643,7 @@ cmd_element_match(struct cmd_element *cmd_element,
{
struct cmd_matcher matcher;
unsigned int token_index;
- enum matcher_rv rv;
+ enum matcher_rv rv = MATCHER_OK;
cmd_matcher_init(&matcher, cmd_element, filter,
vline, index, match_type, match);
diff --git a/lib/distribute.c b/lib/distribute.c
index ba8043cf9..7157d9a5b 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -69,10 +69,11 @@ distribute_lookup (const char *ifname)
struct distribute *dist;
/* temporary reference */
- key.ifname = (char *)ifname;
+ key.ifname = XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname);
dist = hash_lookup (disthash, &key);
-
+ XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
+
return dist;
}
@@ -106,11 +107,15 @@ static struct distribute *
distribute_get (const char *ifname)
{
struct distribute key;
+ struct distribute *ret;
/* temporary reference */
- key.ifname = (char *)ifname;
+ key.ifname = XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname);
- return hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc);
+ ret = hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc);
+
+ XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
+ return ret;
}
static unsigned int
diff --git a/lib/hash.c b/lib/hash.c
index 4d3da66d7..a20093cd6 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -27,7 +27,7 @@
/* Allocate a new hash. */
struct hash *
hash_create_size (unsigned int size, unsigned int (*hash_key) (void *),
- int (*hash_cmp) (const void *, const void *))
+ int (*hash_cmp) (const void *, const void *))
{
struct hash *hash;
diff --git a/lib/hash.h b/lib/hash.h
index 9707dbd1b..0bc3089f3 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -64,7 +64,7 @@ struct hash
extern struct hash *hash_create (unsigned int (*) (void *),
int (*) (const void *, const void *));
extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *),
- int (*) (const void *, const void *));
+ int (*) (const void *, const void *));
extern void *hash_get (struct hash *, void *, void * (*) (void *));
extern void *hash_alloc_intern (void *);
diff --git a/lib/if.c b/lib/if.c
index 4800105dc..0e88c601f 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -350,8 +350,6 @@ struct interface *
if_lookup_prefix (struct prefix *prefix)
{
struct listnode *node;
- struct prefix addr;
- int bestlen = 0;
struct listnode *cnode;
struct interface *ifp;
struct connected *c;
@@ -506,10 +504,6 @@ if_flag_dump (unsigned long flag)
static void
if_dump (const struct interface *ifp)
{
- struct listnode *node;
- struct connected *c;
-
- for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
zlog_info ("Interface %s index %d metric %d mtu %d "
#ifdef HAVE_IPV6
"mtu6 %d "
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index e4a83de8b..26a6d8c55 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -64,10 +64,11 @@ if_rmap_lookup (const char *ifname)
struct if_rmap *if_rmap;
/* temporary copy */
- key.ifname = (char *)ifname;
+ key.ifname = XSTRDUP (MTYPE_IF_RMAP_NAME, ifname);
if_rmap = hash_lookup (ifrmaphash, &key);
+ XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
return if_rmap;
}
@@ -86,7 +87,7 @@ if_rmap_hook_delete (void (*func) (struct if_rmap *))
static void *
if_rmap_hash_alloc (void *arg)
{
- struct if_rmap *ifarg = arg;
+ struct if_rmap *ifarg = (struct if_rmap *)arg;
struct if_rmap *if_rmap;
if_rmap = if_rmap_new ();
@@ -99,11 +100,16 @@ static struct if_rmap *
if_rmap_get (const char *ifname)
{
struct if_rmap key;
+ struct if_rmap *ret;
/* temporary copy */
- key.ifname = (char *)ifname;
+ key.ifname = XSTRDUP (MTYPE_IF_RMAP_NAME, ifname);
- return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+ ret = hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+ if (key.ifname)
+ XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+
+ return ret;
}
static unsigned int
diff --git a/lib/jhash.c b/lib/jhash.c
index 071fed6e6..3cf183299 100644
--- a/lib/jhash.c
+++ b/lib/jhash.c
@@ -42,10 +42,10 @@
* the input key.
*/
u_int32_t
-jhash (void *key, u_int32_t length, u_int32_t initval)
+jhash (const void *key, u_int32_t length, u_int32_t initval)
{
u_int32_t a, b, c, len;
- u_int8_t *k = key;
+ const u_int8_t *k = key;
len = length;
a = b = JHASH_GOLDEN_RATIO;
diff --git a/lib/jhash.h b/lib/jhash.h
index 44dd1b562..a9807cc38 100644
--- a/lib/jhash.h
+++ b/lib/jhash.h
@@ -24,7 +24,7 @@
* of bytes. No alignment or length assumptions are made about
* the input key.
*/
-extern u_int32_t jhash(void *key, u_int32_t length, u_int32_t initval);
+extern u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval);
/* A special optimized version that handles 1 or more of u_int32_ts.
* The length parameter here is the number of u_int32_ts in the key.
diff --git a/lib/libospf.h b/lib/libospf.h
index 76feaa82e..5dc14fa93 100644
--- a/lib/libospf.h
+++ b/lib/libospf.h
@@ -47,8 +47,8 @@
#define OSPF_LSA_MAXAGE_DIFF 900
#define OSPF_LS_INFINITY 0xffffff
#define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
-#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
-#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
+#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001U
+#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffffU
/* OSPF Interface Types */
#define OSPF_IFTYPE_NONE 0
diff --git a/lib/md5.c b/lib/md5.c
index 2fc36e179..80522b6dd 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -360,7 +360,7 @@ caddr_t digest; /* caller digest to be filled in */
* pass */
MD5Update(&context, k_ipad, 64); /* start with inner pad */
MD5Update(&context, text, text_len); /* then text of datagram */
- MD5Final(digest, &context); /* finish up 1st pass */
+ MD5Final((uint8_t *)digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
@@ -369,5 +369,5 @@ caddr_t digest; /* caller digest to be filled in */
MD5Update(&context, k_opad, 64); /* start with outer pad */
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
- MD5Final(digest, &context); /* finish up 2nd pass */
+ MD5Final((uint8_t *)digest, &context); /* finish up 2nd pass */
}
diff --git a/lib/routemap.c b/lib/routemap.c
index 40ba87da4..6203b278d 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -149,7 +149,7 @@ route_map_add (const char *name)
* the delete hook function. Don't invoke delete_hook
* again in this routine.
*/
-void
+static void
route_map_free_map (struct route_map *map)
{
struct route_map_list *list;
@@ -1064,39 +1064,14 @@ route_map_finish (void)
static int
route_map_rmap_hash_cmp (const void *p1, const void *p2)
{
- return (strcmp((char *)p1, (char *)p2) == 0);
+ return (strcmp((const char *)p1, (const char *)p2) == 0);
}
static int
route_map_dep_hash_cmp (const void *p1, const void *p2)
{
- return (strcmp (((struct route_map_dep *)p1)->dep_name, (char *)p2) == 0);
-}
-
-static void
-route_map_rmap_free(struct hash_backet *backet, void *arg)
-{
- char *rmap_name = (char *)backet->data;
-
- if (rmap_name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
-}
-
-static void
-route_map_dep_hash_free (struct hash_backet *backet, void *arg)
-{
- struct route_map_dep *dep = (struct route_map_dep *)backet->data;
-
- if (!dep)
- return;
-
- if (dep->dep_rmap_hash)
- hash_iterate (dep->dep_rmap_hash, route_map_rmap_free, (void *)NULL);
-
- hash_free(dep->dep_rmap_hash);
- XFREE(MTYPE_ROUTE_MAP_NAME, dep->dep_name);
- XFREE(MTYPE_ROUTE_MAP_DEP, dep);
+ return (strcmp (((const struct route_map_dep *)p1)->dep_name, (const char *)p2) == 0);
}
static void
@@ -1152,7 +1127,7 @@ route_map_dep_hash_alloc(void *p)
static void *
route_map_name_hash_alloc(void *p)
{
- return((void *)XSTRDUP(MTYPE_ROUTE_MAP_NAME, (char *)p));
+ return((void *)XSTRDUP(MTYPE_ROUTE_MAP_NAME, (const char *)p));
}
static unsigned int
@@ -1178,6 +1153,11 @@ route_map_dep_update (struct hash *dephash, const char *dep_name,
{
struct route_map_dep *dep;
char *ret_map_name;
+ char *dname, *rname;
+ int ret = 0;
+
+ dname = XSTRDUP(MTYPE_ROUTE_MAP_NAME, dep_name);
+ rname = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name);
switch (type)
{
@@ -1190,15 +1170,17 @@ route_map_dep_update (struct hash *dephash, const char *dep_name,
if (rmap_debug)
zlog_debug("%s: Adding dependency for %s in %s", __FUNCTION__,
dep_name, rmap_name);
- dep = (struct route_map_dep *) hash_get (dephash, (void *)dep_name,
+ dep = (struct route_map_dep *) hash_get (dephash, dname,
route_map_dep_hash_alloc);
- if (!dep)
- return -1;
+ if (!dep) {
+ ret = -1;
+ goto out;
+ }
if (!dep->this_hash)
dep->this_hash = dephash;
- hash_get(dep->dep_rmap_hash, rmap_name, route_map_name_hash_alloc);
+ hash_get(dep->dep_rmap_hash, rname, route_map_name_hash_alloc);
break;
case RMAP_EVENT_PLIST_DELETED:
case RMAP_EVENT_CLIST_DELETED:
@@ -1209,17 +1191,18 @@ route_map_dep_update (struct hash *dephash, const char *dep_name,
if (rmap_debug)
zlog_debug("%s: Deleting dependency for %s in %s", __FUNCTION__,
dep_name, rmap_name);
- dep = (struct route_map_dep *) hash_get (dephash, (void *)dep_name,
- NULL);
- if (!dep)
- return 0;
- ret_map_name = (char *)hash_release(dep->dep_rmap_hash, (void *)rmap_name);
+ dep = (struct route_map_dep *) hash_get (dephash, dname, NULL);
+ if (!dep) {
+ goto out;
+ }
+
+ ret_map_name = (char *)hash_release(dep->dep_rmap_hash, rname);
if (ret_map_name)
XFREE(MTYPE_ROUTE_MAP_NAME, ret_map_name);
if (!dep->dep_rmap_hash->count)
{
- dep = hash_release(dephash, (void *)dep_name);
+ dep = hash_release(dephash, dname);
hash_free(dep->dep_rmap_hash);
XFREE(MTYPE_ROUTE_MAP_NAME, dep->dep_name);
XFREE(MTYPE_ROUTE_MAP_DEP, dep);
@@ -1233,9 +1216,13 @@ route_map_dep_update (struct hash *dephash, const char *dep_name,
if (dep)
{
if (rmap_debug)
- hash_iterate (dep->dep_rmap_hash, route_map_print_dependency, (void *)dep_name);
+ hash_iterate (dep->dep_rmap_hash, route_map_print_dependency, dname);
}
- return 0;
+
+ out:
+ XFREE(MTYPE_ROUTE_MAP_NAME, rname);
+ XFREE(MTYPE_ROUTE_MAP_NAME, dname);
+ return ret;
}
static struct hash *
@@ -1309,14 +1296,17 @@ route_map_notify_dependencies (const char *affected_name, route_map_event_t even
{
struct route_map_dep *dep;
struct hash *upd8_hash;
+ char *name;
if (!affected_name)
return;
+ name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, affected_name);
+
if ((upd8_hash = route_map_get_dep_hash(event)) == NULL)
return;
- dep = (struct route_map_dep *)hash_get (upd8_hash, (void *)affected_name,
+ dep = (struct route_map_dep *)hash_get (upd8_hash, name,
NULL);
if (dep)
{
@@ -1325,6 +1315,8 @@ route_map_notify_dependencies (const char *affected_name, route_map_event_t even
hash_iterate (dep->dep_rmap_hash, route_map_process_dependency, (void *)event);
}
+
+ XFREE (MTYPE_ROUTE_MAP_NAME, name);
}
/* VTY related functions. */
diff --git a/lib/routemap.h b/lib/routemap.h
index 49191b17e..280601b52 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -22,6 +22,8 @@
#ifndef _ZEBRA_ROUTEMAP_H
#define _ZEBRA_ROUTEMAP_H
+#include "prefix.h"
+
/* Route map's type. */
enum route_map_type
{
diff --git a/lib/table.c b/lib/table.c
index 220e9b81e..bd7023c12 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -626,11 +626,8 @@ route_table_get_next_internal (const struct route_table *table,
struct prefix *p)
{
struct route_node *node, *tmp_node;
- u_char prefixlen;
int cmp;
- prefixlen = p->prefixlen;
-
node = table->top;
while (node)
diff --git a/lib/thread.c b/lib/thread.c
index 00d0a639a..4f3879df3 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -662,7 +662,7 @@ thread_timer_remain_second (struct thread *thread)
}
/* Trim blankspace and "()"s */
-void
+static void
strip_funcname (char *dest, const char *funcname)
{
char buff[FUNCNAME_LEN];
diff --git a/lib/vty.c b/lib/vty.c
index 114135760..41e340131 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2449,10 +2449,11 @@ vty_log (const char *level, const char *proto_str,
/* Async-signal-safe version of vty_log for fixed strings. */
void
-vty_log_fixed (const char *buf, size_t len)
+vty_log_fixed (char *buf, size_t len)
{
unsigned int i;
struct iovec iov[2];
+ char crlf[4] = "\r\n";
/* vty may not have been initialised */
if (!vtyvec)
@@ -2460,7 +2461,7 @@ vty_log_fixed (const char *buf, size_t len)
iov[0].iov_base = (void *)buf;
iov[0].iov_len = len;
- iov[1].iov_base = (void *)"\r\n";
+ iov[1].iov_base = crlf;
iov[1].iov_len = 2;
for (i = 0; i < vector_active (vtyvec); i++)
diff --git a/lib/vty.h b/lib/vty.h
index 4d42a6d8b..bce6c80bf 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -255,6 +255,6 @@ extern void vty_hello (struct vty *);
/* Send a fixed-size message to all vty terminal monitors; this should be
an async-signal-safe function. */
-extern void vty_log_fixed (const char *buf, size_t len);
+extern void vty_log_fixed (char *buf, size_t len);
#endif /* _ZEBRA_VTY_H */
diff --git a/lib/workqueue.c b/lib/workqueue.c
index a7f4b7071..6fad237e1 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -30,7 +30,11 @@
#include "log.h"
/* master list of work_queues */
-static struct list work_queues;
+static struct list _work_queues;
+/* pointer primarly to avid an otherwise harmless warning on
+ * ALL_LIST_ELEMENTS_RO
+ */
+static struct list *work_queues = &_work_queues;
#define WORK_QUEUE_MIN_GRANULARITY 1
@@ -78,7 +82,7 @@ work_queue_new (struct thread_master *m, const char *queue_name)
new->items->del = (void (*)(void *)) work_queue_item_free;
- listnode_add (&work_queues, new);
+ listnode_add (work_queues, new);
new->cycles.granularity = WORK_QUEUE_MIN_GRANULARITY;
@@ -97,7 +101,7 @@ work_queue_free (struct work_queue *wq)
/* list_delete frees items via callback */
list_delete (wq->items);
- listnode_delete (&work_queues, wq);
+ listnode_delete (work_queues, wq);
XFREE (MTYPE_WORK_QUEUE_NAME, wq->name);
XFREE (MTYPE_WORK_QUEUE, wq);
@@ -191,7 +195,7 @@ DEFUN(show_work_queues,
"Name",
VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO ((&work_queues), node, wq))
+ for (ALL_LIST_ELEMENTS_RO (work_queues, node, wq))
{
vty_out (vty,"%c %8d %5d %8ld %8ld %7d %6d %8ld %6u %s%s",
(CHECK_FLAG (wq->flags, WQ_UNPLUGGED) ? ' ' : 'P'),
diff --git a/lib/zclient.c b/lib/zclient.c
index f6ac92457..3248d00ca 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -116,7 +116,7 @@ redist_del_instance (struct redist_proto *red, u_short instance)
u_short *id = NULL;
if (!red->instances)
- return 0;
+ return;
for (ALL_LIST_ELEMENTS_RO (red->instances, node, id))
if (*id == instance)