From 98a306ff278884bfcbea41b059f2467226a9ced9 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 29 Jan 2018 12:10:25 +0100 Subject: lib: Fix bad comparison in timerwheel A comparison was done in the timerwheel between an unsigned value and a time_t. Signed-off-by: Sander Vrijders Signed-off-by: Dimitri Staessens --- src/lib/timerwheel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c index 391e805b..60fa9cda 100644 --- a/src/lib/timerwheel.c +++ b/src/lib/timerwheel.c @@ -60,7 +60,7 @@ struct timerwheel { pthread_mutex_t lock; time_t resolution; - unsigned int elements; + size_t elements; }; static void tw_el_fini(struct tw_el * e) @@ -111,7 +111,7 @@ struct timerwheel * timerwheel_create(time_t resolution, struct timespec now = {0, 0}; struct timespec res_ts = {resolution / 1000, (resolution % 1000) * MILLION}; - unsigned long i; + size_t i; struct timerwheel * tw; @@ -126,7 +126,7 @@ struct timerwheel * timerwheel_create(time_t resolution, tw->elements = 1; - while (tw->elements < max_delay / resolution) + while (tw->elements < (size_t) max_delay / resolution) tw->elements <<= 1; tw->wheel = malloc(sizeof(*tw->wheel) * tw->elements); -- cgit v1.2.3