bgpd: random() returns long
bgpd was using unsigned to store a probability value to be used with
random(). That, however, returns long, running into some warnings (and
worst case, if RAND_MAX > UINT_MAX, won't work correctly.
Just use long to shuffle the value around.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 95f1dff..33f802c 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -826,12 +826,12 @@
r = (long) rand();
#endif
- switch (*(unsigned *) rule)
+ switch (*(long *) rule)
{
case 0: break;
case RAND_MAX: return RMAP_MATCH;
default:
- if (r < *(unsigned *) rule)
+ if (r < *(long *) rule)
{
return RMAP_MATCH;
}
@@ -843,7 +843,7 @@
static void *
route_match_probability_compile (const char *arg)
{
- unsigned *lobule;
+ long *lobule;
unsigned perc;
#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
@@ -853,7 +853,7 @@
#endif
perc = atoi (arg);
- lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned));
+ lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (long));
switch (perc)
{