Commit c4e6bf0e authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make sundry time values be unsigned.

parent 7e04f06d
...@@ -491,7 +491,7 @@ flushbuf(struct network *net) ...@@ -491,7 +491,7 @@ flushbuf(struct network *net)
static void static void
schedule_flush(struct network *net) schedule_flush(struct network *net)
{ {
int msecs = jitter(net, 0); unsigned msecs = jitter(net, 0);
if(net->flush_timeout.tv_sec != 0 && if(net->flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&net->flush_timeout, &now) < msecs) timeval_minus_msec(&net->flush_timeout, &now) < msecs)
return; return;
...@@ -504,7 +504,7 @@ static void ...@@ -504,7 +504,7 @@ static void
schedule_flush_now(struct network *net) schedule_flush_now(struct network *net)
{ {
/* Almost now */ /* Almost now */
int msecs = roughly(10); unsigned msecs = roughly(10);
if(net->flush_timeout.tv_sec != 0 && if(net->flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&net->flush_timeout, &now) < msecs) timeval_minus_msec(&net->flush_timeout, &now) < msecs)
return; return;
...@@ -514,12 +514,10 @@ schedule_flush_now(struct network *net) ...@@ -514,12 +514,10 @@ schedule_flush_now(struct network *net)
} }
static void static void
schedule_unicast_flush(int msecs) schedule_unicast_flush(unsigned msecs)
{ {
if(!unicast_neighbour) if(!unicast_neighbour)
return; return;
if(msecs < 0)
msecs = jitter(unicast_neighbour->network, 1);
if(unicast_flush_timeout.tv_sec != 0 && if(unicast_flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&unicast_flush_timeout, &now) < msecs) timeval_minus_msec(&unicast_flush_timeout, &now) < msecs)
return; return;
...@@ -926,7 +924,7 @@ flushupdates(void) ...@@ -926,7 +924,7 @@ flushupdates(void)
static void static void
schedule_update_flush(struct network *net, int urgent) schedule_update_flush(struct network *net, int urgent)
{ {
int msecs; unsigned msecs;
msecs = update_jitter(net, urgent); msecs = update_jitter(net, urgent);
if(update_flush_timeout.tv_sec != 0 && if(update_flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&update_flush_timeout, &now) < msecs) timeval_minus_msec(&update_flush_timeout, &now) < msecs)
......
...@@ -198,7 +198,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval) ...@@ -198,7 +198,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
static int static int
reset_txcost(struct neighbour *neigh) reset_txcost(struct neighbour *neigh)
{ {
int delay; unsigned delay;
delay = timeval_minus_msec(&now, &neigh->ihu_time); delay = timeval_minus_msec(&now, &neigh->ihu_time);
...@@ -228,8 +228,8 @@ unsigned ...@@ -228,8 +228,8 @@ unsigned
check_neighbours() check_neighbours()
{ {
struct neighbour *neigh; struct neighbour *neigh;
int changed, delay; int changed;
int msecs = 50000; unsigned msecs = 50000, delay;
debugf("Checking neighbours.\n"); debugf("Checking neighbours.\n");
...@@ -268,7 +268,7 @@ check_neighbours() ...@@ -268,7 +268,7 @@ check_neighbours()
unsigned unsigned
neighbour_rxcost(struct neighbour *neigh) neighbour_rxcost(struct neighbour *neigh)
{ {
int delay; unsigned delay;
unsigned short reach = neigh->reach; unsigned short reach = neigh->reach;
delay = timeval_minus_msec(&now, &neigh->hello_time); delay = timeval_minus_msec(&now, &neigh->hello_time);
......
...@@ -114,7 +114,7 @@ update_hello_interval(struct network *net) ...@@ -114,7 +114,7 @@ update_hello_interval(struct network *net)
/* This should be no more than half the hello interval, so that hellos /* This should be no more than half the hello interval, so that hellos
aren't sent late. The result is in milliseconds. */ aren't sent late. The result is in milliseconds. */
unsigned int unsigned
jitter(struct network *net, int urgent) jitter(struct network *net, int urgent)
{ {
unsigned interval = net->hello_interval; unsigned interval = net->hello_interval;
...@@ -125,7 +125,7 @@ jitter(struct network *net, int urgent) ...@@ -125,7 +125,7 @@ jitter(struct network *net, int urgent)
return roughly(interval) / 4; return roughly(interval) / 4;
} }
unsigned int unsigned
update_jitter(struct network *net, int urgent) update_jitter(struct network *net, int urgent)
{ {
unsigned interval = net->hello_interval; unsigned interval = net->hello_interval;
......
...@@ -63,8 +63,8 @@ extern int numnets; ...@@ -63,8 +63,8 @@ extern int numnets;
struct network *add_network(char *ifname); struct network *add_network(char *ifname);
int network_idle(struct network *net); int network_idle(struct network *net);
int update_hello_interval(struct network *net); int update_hello_interval(struct network *net);
unsigned int jitter(struct network *net, int urgent); unsigned jitter(struct network *net, int urgent);
unsigned int update_jitter(struct network *net, int urgent); unsigned update_jitter(struct network *net, int urgent);
void delay_jitter(struct timeval *time, struct timeval *timeout, int msecs); void delay_jitter(struct timeval *time, struct timeval *timeout, int msecs);
int network_up(struct network *net, int up); int network_up(struct network *net, int up);
int network_ll_address(struct network *net, const unsigned char *address); int network_ll_address(struct network *net, const unsigned char *address);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment