diff --git a/src/counters.c b/src/counters.c index d50007c7d6..6040642020 100644 --- a/src/counters.c +++ b/src/counters.c @@ -51,7 +51,7 @@ * \brief Different kinds of qualifier that can be used to modify the behaviour * of the counter to be registered */ -enum { +enum StatsType { STATS_TYPE_NORMAL = 1, STATS_TYPE_AVERAGE = 2, STATS_TYPE_MAXIMUM = 3, @@ -622,7 +622,7 @@ static uint16_t GetIdByName(const StatsPublicThreadContext *pctx, const char *na * \retval 0 on failure */ static uint16_t StatsRegisterQualifiedCounter(const char *name, StatsPublicThreadContext *pctx, - int type_q, uint64_t (*Func)(void), const char *dname1, const char *dname2) + enum StatsType type_q, uint64_t (*Func)(void), const char *dname1, const char *dname2) { StatsCounter **head = &pctx->head; StatsCounter *temp = NULL; @@ -738,7 +738,7 @@ static int StatsOutput(ThreadVars *tv) /** temporary local table to merge the per thread counters, * especially needed for the average counters */ struct CountersMergeTable { - int type; + enum StatsType type; int64_t value; uint64_t updates; } merge_table[max_id]; @@ -818,7 +818,7 @@ static int StatsOutput(ThreadVars *tv) /* update merge table */ for (uint16_t c = 0; c < max_id; c++) { - struct CountersMergeTable *e = &thread_table[c]; + const struct CountersMergeTable *e = &thread_table[c]; /* thread only sets type if it has a counter * of this type. */ if (e->type == 0) @@ -843,7 +843,7 @@ static int StatsOutput(ThreadVars *tv) /* update per thread stats table */ for (uint16_t c = 0; c < max_id; c++) { - struct CountersMergeTable *e = &thread_table[c]; + const struct CountersMergeTable *e = &thread_table[c]; /* thread only sets type if it has a counter * of this type. */ if (e->type == 0) @@ -883,7 +883,7 @@ static int StatsOutput(ThreadVars *tv) table[x].value = 0; table[x].tm_name = "Total"; - struct CountersMergeTable *m = &merge_table[x]; + const struct CountersMergeTable *m = &merge_table[x]; switch (m->type) { case STATS_TYPE_MAXIMUM: if (m->value > table[x].value) diff --git a/src/counters.h b/src/counters.h index b8a889d734..6552cc4560 100644 --- a/src/counters.h +++ b/src/counters.h @@ -53,7 +53,7 @@ typedef struct StatsCounterDeriveId { * \brief Container to hold the counter variable */ typedef struct StatsCounter_ { - int type; + int type; /**< enum StatsType from counters.c */ /* local id for this counter in this thread */ uint16_t id; @@ -66,7 +66,7 @@ typedef struct StatsCounter_ { uint16_t did1; uint16_t did2; - /* when using type STATS_TYPE_Q_FUNC this function is called once + /* when using type STATS_TYPE_FUNC this function is called once * to get the counter value, regardless of how many threads there are. */ uint64_t (*Func)(void);