diff --git a/src/FTL.h b/src/FTL.h index 1443b62e0..0d1280a15 100644 --- a/src/FTL.h +++ b/src/FTL.h @@ -59,11 +59,11 @@ #define MAXITER 1000 // How many hours do we want to store in FTL's memory? [hours] -#define MAXLOGAGE 24 +#define MAXLOGAGE 24u // Interval for overTime data [seconds] // Default: 600 (10 minutes) -#define OVERTIME_INTERVAL 600 +#define OVERTIME_INTERVAL 600u // How many overTime slots do we need? // This is the maximum log age divided by the overtime interval diff --git a/src/database/aliasclients.c b/src/database/aliasclients.c index cf9180fdc..4a2010a63 100644 --- a/src/database/aliasclients.c +++ b/src/database/aliasclients.c @@ -84,7 +84,7 @@ static void recompute_aliasclient(const int aliasclientID) // Add counts of this client to the alias-client aliasclient->count += client->count; aliasclient->blockedcount += client->blockedcount; - for(int idx = 0; idx < OVERTIME_SLOTS; idx++) + for(unsigned int idx = 0; idx < OVERTIME_SLOTS; idx++) aliasclient->overTime[idx] += client->overTime[idx]; } } diff --git a/src/datastructure.c b/src/datastructure.c index 6db83f69c..1c8fc2a7f 100644 --- a/src/datastructure.c +++ b/src/datastructure.c @@ -414,7 +414,7 @@ void change_clientcount(clientsData *client, int total, int blocked, int overTim { client->count += total; client->blockedcount += blocked; - if(overTimeIdx > -1 && overTimeIdx < OVERTIME_SLOTS) + if(overTimeIdx > -1 && (unsigned int)overTimeIdx < OVERTIME_SLOTS) { overTime[overTimeIdx].total += overTimeMod; client->overTime[overTimeIdx] += overTimeMod; @@ -432,7 +432,7 @@ void change_clientcount(clientsData *client, int total, int blocked, int overTim clientsData *aliasclient = getClient(client->aliasclient_id, true); aliasclient->count += total; aliasclient->blockedcount += blocked; - if(overTimeIdx > -1 && overTimeIdx < OVERTIME_SLOTS) + if(overTimeIdx > -1 && (unsigned int)overTimeIdx < OVERTIME_SLOTS) aliasclient->overTime[overTimeIdx] += overTimeMod; } } diff --git a/src/gc.c b/src/gc.c index 2235a722b..dfc9192a9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -263,7 +263,7 @@ static void recycle(void) * * @return The maximum overtime slot as an unsigned integer. */ -unsigned int get_max_overtime_slot(void) +unsigned int __attribute__((pure)) get_max_overtime_slot(void) { return min(config.webserver.api.maxHistory.v.ui, MAXLOGAGE * 3600) / OVERTIME_INTERVAL - 1; } diff --git a/src/gc.h b/src/gc.h index 48aa5045b..cb078a11d 100644 --- a/src/gc.h +++ b/src/gc.h @@ -15,7 +15,7 @@ void *GC_thread(void *val); void runGC(const time_t now, time_t *lastGCrun, const bool flush); -unsigned int get_max_overtime_slot(void); +unsigned int get_max_overtime_slot(void) __attribute__((pure)); int get_rate_limit_turnaround(const unsigned int rate_limit_count); unsigned int set_gc_interval(void); diff --git a/src/overTime.c b/src/overTime.c index 9dca275ba..5c327f492 100644 --- a/src/overTime.c +++ b/src/overTime.c @@ -85,12 +85,12 @@ void initOverTime(void) localtime_r(&newest, &tm_n); strftime(first, 20, "%Y-%m-%d %H:%M:%S", &tm_o); strftime(last, 20, "%Y-%m-%d %H:%M:%S", &tm_n); - log_debug(DEBUG_OVERTIME, "initOverTime(): Initializing %i slots from %s (%lu) to %s (%lu)", + log_debug(DEBUG_OVERTIME, "initOverTime(): Initializing %u slots from %s (%lu) to %s (%lu)", OVERTIME_SLOTS, first, (unsigned long)oldest, last, (unsigned long)newest); } // Iterate over overTime - for(int i = 0; i < OVERTIME_SLOTS; i++) + for(unsigned int i = 0; i < OVERTIME_SLOTS; i++) { time_t this_slot_ts = oldest + OVERTIME_INTERVAL * i; // Initialize overTime slot @@ -117,14 +117,14 @@ unsigned int _getOverTimeID(time_t timestamp, const char *file, const int line) // Return first timestamp in case negative timestamp was determined return 0; } - else if(id == OVERTIME_SLOTS) + else if((unsigned int)id == OVERTIME_SLOTS) { // Possible race-collision (moving of the timeslots is just about to // happen), silently add to the last bin because this is the correct // thing to do return OVERTIME_SLOTS-1; } - else if(id > OVERTIME_SLOTS) + else if((unsigned int)id > OVERTIME_SLOTS) { // This is definitely wrong. We warn about this (but only once) if(!warned_about_hwclock)