ctrl: log incorrect interval values
This should never happen with the current code, but if it ever does, we
should log the error instead of silently returning 0.
Change-Id: I544001d3072e5f12a96a67e4178f9b945c5f6b6c
Related: OS#2550
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 665239a..590f74d 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -483,10 +483,13 @@
return ret;
}
-static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv)
+static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv, const char *grp)
{
- if (intv >= RATE_CTR_INTV_NUM)
+ if (intv >= RATE_CTR_INTV_NUM) {
+ LOGP(DLCTRL, LOGL_ERROR, "Unexpected interval value %d while trying to get rate counter value in %s\n",
+ intv, grp);
return 0;
+ }
/* Absolute value */
if (intv == -1) {
@@ -507,7 +510,7 @@
counters = talloc_asprintf_append(counters, "\n%s.%u.%s %"PRIu64,
ctrg->desc->group_name_prefix, ctrg->idx,
ctrg->desc->ctr_desc[i].name,
- get_rate_ctr_value(&ctrg->ctr[i], intv));
+ get_rate_ctr_value(&ctrg->ctr[i], intv, ctrg->desc->group_name_prefix));
if (!counters)
return NULL;
}
@@ -630,7 +633,7 @@
talloc_free(dup);
- cmd->reply = talloc_asprintf(cmd, "%"PRIu64, get_rate_ctr_value(ctr, intv));
+ cmd->reply = talloc_asprintf(cmd, "%"PRIu64, get_rate_ctr_value(ctr, intv, ctrg->desc->group_name_prefix));
if (!cmd->reply)
goto oom;