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>
(cherry picked from commit
8c9cd85631b77fac0bc30ffb9f23b29c466d31c4)
r = (unsigned 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;
}
static void *
route_match_probability_compile (const char *arg)
{
- unsigned *lobule;
+ long *lobule;
unsigned perc;
#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
#endif
perc = atoi (arg);
- lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned));
+ lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (long));
switch (perc)
{