From 0cd557639c622fd1d98bced76fc13ef8d80ee6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sat, 23 Jan 2021 11:15:49 +0100 Subject: [PATCH 3/3] - Change invocation of non-existed function to correct invocation - Added assertions, when needed - Remove bug caused returning integer instead of pointer. Additionally, previously function returns given parameter instead of pointer to struct this parameter is related to. diff --git a/common/counters.c b/common/counters.c index 36ab32c6d1..33c836818d 100644 --- a/common/counters.c +++ b/common/counters.c @@ -15,6 +15,8 @@ #include #endif +#include "fcintl.h" + #include "counters.h" @@ -62,7 +64,7 @@ struct counter *counter_by_id(int id) if (counters[i].id == id) { - return id; + return &counters[i]; } } @@ -74,6 +76,7 @@ struct counter *counter_by_id(int id) ****************************************************************************/ int counter_id(struct counter *pcount) { + fc_assert_ret_val(NULL != pcount, -1); return pcount->id; } @@ -87,9 +90,9 @@ struct counter *counter_by_rule_name(const char *name) for (i = 0; i < MAX_COUNTERS; ++i) { - if (0 == fc_casestrcmp(name,counters[i] .rule_name)) { + if (0 == fc_strcasecmp(name,counters[i] .rule_name)) { - return id; + return &counters[i]; } } @@ -109,6 +112,7 @@ const char *counter_rule_name(struct counter *pcount) ****************************************************************************/ int counter_index(struct counter *pcount) { + fc_assert_ret_val(NULL != pcount, -1); return pcount - counters; } -- 2.30.0