[PATCH] libosmocore[master]: ctrl: log incorrect interval values

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Nov 24 12:54:31 UTC 2017


Review at  https://gerrit.osmocom.org/5025

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
---
M src/ctrl/control_if.c
1 file changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/5025/1

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;
 

-- 
To view, visit https://gerrit.osmocom.org/5025
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I544001d3072e5f12a96a67e4178f9b945c5f6b6c
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list