Change in libosmocore[master]: Use new stat item/ctr getter APIs

pespin gerrit-no-reply at lists.osmocom.org
Fri Jun 4 16:20:02 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24561 )


Change subject: Use new stat item/ctr getter APIs
......................................................................

Use new stat item/ctr getter APIs

Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

"""
@@
expression E1, E2, E3;
@@
- E2->items[E1]
+ osmo_stat_item_group_get_item(E2, E1)
"""

Change-Id: I41297a8df68e28dfc6016330ac82b0ed5dd0ebc1
---
M src/ctrl/control_if.c
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_bss.c
M src/gb/gprs_ns.c
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_message.c
M src/gb/gprs_ns2_vc_fsm.c
M tests/gb/gprs_ns_test.c
M tests/stats/stats_test.c
10 files changed, 93 insertions(+), 93 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/61/24561/1

diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 5eb81c7..d117fcf 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -589,12 +589,12 @@
 	}
 }
 
-static int get_rate_ctr_group_idx(const struct rate_ctr_group *ctrg, int intv, struct ctrl_cmd *cmd)
+static int get_rate_ctr_group_idx(struct rate_ctr_group *ctrg, int intv, struct ctrl_cmd *cmd)
 {
 	unsigned int i;
 	for (i = 0; i < ctrg->desc->num_ctr; i++) {
 		ctrl_cmd_reply_printf(cmd, "%s %"PRIu64";", ctrg->desc->ctr_desc[i].name,
-				      get_rate_ctr_value(&ctrg->ctr[i], intv, ctrg->desc->group_name_prefix));
+				      get_rate_ctr_value(rate_ctr_group_get_ctr(ctrg, i), intv, ctrg->desc->group_name_prefix));
 		if (!cmd->reply) {
 			cmd->reply = "OOM";
 			return CTRL_CMD_ERROR;
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 207c9a8..14a5e9d 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -441,7 +441,7 @@
 		return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
 
 	ptp_ctx->state |= BVC_S_BLOCKED;
-	rate_ctr_inc(&ptp_ctx->ctrg->ctr[BSSGP_CTR_BLOCKED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(ptp_ctx->ctrg, BSSGP_CTR_BLOCKED));
 
 	/* Send NM_BVC_BLOCK.ind to NM */
 	memset(&nmp, 0, sizeof(nmp));
@@ -634,7 +634,7 @@
 	DEBUGP(DLBSSGP, "BSSGP BVCI=%u TLLI=%08x Rx LLC DISCARDED\n",
 		ctx->bvci, tlli);
 
-	rate_ctr_inc(&ctx->ctrg->ctr[BSSGP_CTR_DISCARDED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(ctx->ctrg, BSSGP_CTR_DISCARDED));
 
 	/* send NM_LLC_DISCARDED to NM */
 	memset(&nmp, 0, sizeof(nmp));
@@ -675,7 +675,7 @@
 	}
 
 	if (bctx)
-		rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_STATUS]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_STATUS));
 
 	/* send NM_STATUS to NM */
 	memset(&nmp, 0, sizeof(nmp));
@@ -1194,8 +1194,8 @@
 
 	if (bctx) {
 		log_set_context(LOG_CTX_GB_BVC, bctx);
-		rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]);
-		rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN],
+		rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_PKTS_IN));
+		rate_ctr_add(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_BYTES_IN),
 			     msgb_bssgp_len(msg));
 	}
 
@@ -1319,8 +1319,8 @@
 	budh->tlli = osmo_htonl(msgb_tlli(msg));
 	budh->pdu_type = BSSGP_PDUT_DL_UNITDATA;
 
-	rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_OUT]);
-	rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_OUT], msg->len);
+	rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_PKTS_OUT));
+	rate_ctr_add(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_BYTES_OUT), msg->len);
 
 	/* Identifiers down: BVCI, NSEI (in msgb->cb) */
 
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index a066e91..8230d87 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -466,8 +466,8 @@
 	msgb_nsei(msg) = bctx->nsei;
 	msgb_bvci(msg) = bctx->bvci;
 
-	rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_OUT]);
-	rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_OUT], msg->len);
+	rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_PKTS_OUT));
+	rate_ctr_add(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_BYTES_OUT), msg->len);
 
 	return bssgp_ns_send(bssgp_ns_send_data, msg);
 }
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index f486333..6046dea 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -486,8 +486,8 @@
 	}
 
 	/* Increment number of Uplink bytes */
-	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
-	rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT], msgb_l2len(msg));
+	rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_PKTS_OUT));
+	rate_ctr_add(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BYTES_OUT), msgb_l2len(msg));
 
 	switch (nsvc->ll) {
 	case GPRS_NS_LL_UDP:
@@ -643,7 +643,7 @@
 
 	/* be conservative and mark it as blocked even now! */
 	ns_mark_blocked(nsvc);
-	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BLOCKED));
 
 	msg->l2h = msgb_put(msg, sizeof(*nsh));
 	nsh = (struct gprs_ns_hdr *) msg->l2h;
@@ -781,15 +781,15 @@
 	switch (nsvc->timer_mode) {
 	case NSVC_TIMER_TNS_ALIVE:
 		/* Tns-alive case: we expired without response ! */
-		rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_LOST_ALIVE]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_LOST_ALIVE));
 		nsvc->alive_retries++;
 		if (nsvc->alive_retries >
 			nsvc->nsi->timeout[NS_TOUT_TNS_ALIVE_RETRIES]) {
 			/* mark as dead (and blocked unless IP-SNS) */
-			rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_DEAD]);
+			rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_DEAD));
 			if (!nsvc->nsi->bss_sns_fi && nsvc->nsi->nsip.use_reset_block_unblock) {
 				ns_set_state(nsvc, NSE_S_BLOCKED);
-				rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]);
+				rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BLOCKED));
 			} else
 				ns_set_state(nsvc, 0);
 			LOGP(DNS, LOGL_NOTICE,
@@ -816,7 +816,7 @@
 		nsvc_start_timer(nsvc, NSVC_TIMER_TNS_ALIVE);
 		break;
 	case NSVC_TIMER_TNS_RESET:
-		rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_LOST_RESET]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_LOST_RESET));
 		if (!(nsvc->state & NSE_S_RESET))
 			LOGP(DNS, LOGL_NOTICE,
 				"NSEI=%u Reset timed out but RESET flag is not set\n",
@@ -1251,7 +1251,7 @@
 			ns_osmo_signal_dispatch_mismatch(*nsvc, msg,
 							 NS_PDUT_RESET,
 							 NS_IE_VCI);
-			rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_INV_VCI]);
+			rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_INV_VCI));
 			gprs_ns_tx_reset_ack(*nsvc);
 			return 0;
 		}
@@ -1277,14 +1277,14 @@
 			ns_osmo_signal_dispatch_mismatch(*nsvc, msg,
 							 NS_PDUT_RESET,
 							 NS_IE_NSEI);
-			rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_INV_NSEI]);
+			rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_INV_NSEI));
 			rc = gprs_ns_tx_reset_ack(*nsvc);
 			CHECK_TX_RC(rc, *nsvc);
 			return 0;
 		}
 
 		/* NSEI has changed */
-		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_NSEI_CHG]);
+		rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_NSEI_CHG));
 		(*nsvc)->nsei = nsei;
 	}
 
@@ -1292,7 +1292,7 @@
 	ns_set_state(*nsvc, NSE_S_BLOCKED | NSE_S_ALIVE);
 
 	if (orig_nsvc) {
-		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
+		rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_REPLACED));
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */
@@ -1390,7 +1390,7 @@
 			ns_osmo_signal_dispatch_mismatch(*nsvc, msg,
 							 NS_PDUT_RESET_ACK,
 							 NS_IE_VCI);
-			rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_INV_VCI]);
+			rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_INV_VCI));
 			LOGP(DNS, LOGL_ERROR,
 			     "NS RESET ACK Unknown NS-VCI %d (%s NSEI=%d) "
 			     "from %s\n",
@@ -1401,7 +1401,7 @@
 		}
 
 		/* Notify others */
-		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
+		rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_REPLACED));
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */
@@ -1415,7 +1415,7 @@
 			ns_osmo_signal_dispatch_mismatch(*nsvc, msg,
 							 NS_PDUT_RESET_ACK,
 							 NS_IE_NSEI);
-			rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_INV_NSEI]);
+			rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_INV_NSEI));
 			LOGP(DNS, LOGL_ERROR,
 			     "NS RESET ACK Unknown NSEI %d (NS-VCI=%u) from %s\n",
 			     nsei, nsvci, gprs_ns_ll_str(*nsvc));
@@ -1423,14 +1423,14 @@
 		}
 
 		/* NSEI has changed */
-		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_NSEI_CHG]);
+		rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_NSEI_CHG));
 		(*nsvc)->nsei = nsei;
 	}
 
 	/* Mark NS-VC as blocked and alive */
 	ns_set_state(*nsvc, NSE_S_BLOCKED | NSE_S_ALIVE);
 	ns_set_remote_state(*nsvc, NSE_S_BLOCKED | NSE_S_ALIVE);
-	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_BLOCKED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_BLOCKED));
 	if ((*nsvc)->persistent || (*nsvc)->remote_end_is_sgsn) {
 		/* stop RESET timer */
 		osmo_timer_del(&(*nsvc)->timer);
@@ -1471,7 +1471,7 @@
 	//nsvci = (uint16_t *) TLVP_VAL(&tp, NS_IE_VCI);
 
 	ns_osmo_signal_dispatch(nsvc, S_NS_BLOCK, *cause);
-	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BLOCKED));
 
 	return gprs_ns_tx_block_ack(nsvc);
 }
@@ -1705,7 +1705,7 @@
 		existing_nsvc->nsei  = nsei;
 
 		/* Do statistics */
-		rate_ctr_inc(&existing_nsvc->ctrg->ctr[NS_CTR_NSEI_CHG]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(existing_nsvc->ctrg, NS_CTR_NSEI_CHG));
 	}
 
 	*new_nsvc = existing_nsvc;
@@ -1734,8 +1734,8 @@
 	log_set_context(LOG_CTX_GB_NSVC, *nsvc);
 
 	/* Increment number of Incoming bytes */
-	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]);
-	rate_ctr_add(&(*nsvc)->ctrg->ctr[NS_CTR_BYTES_IN], msgb_l2len(msg));
+	rate_ctr_inc(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_PKTS_IN));
+	rate_ctr_add(rate_ctr_group_get_ctr((*nsvc)->ctrg, NS_CTR_BYTES_IN), msgb_l2len(msg));
 
 	if (nsvc_is_not_used(*nsvc) && !ns_is_sns(nsh->pdu_type) && nsh->pdu_type != NS_PDUT_STATUS) {
 		LOGP(DNS, LOGL_NOTICE, "NSEI=%u Rx %s on unused/pre-configured endpoint, discarding\n",
@@ -1762,7 +1762,7 @@
 	case NS_PDUT_ALIVE_ACK:
 		ns_mark_alive(*nsvc);
 		if ((*nsvc)->timer_mode == NSVC_TIMER_TNS_ALIVE)
-			osmo_stat_item_set((*nsvc)->statg->items[NS_STAT_ALIVE_DELAY],
+			osmo_stat_item_set(osmo_stat_item_group_get_item((*nsvc)->statg, NS_STAT_ALIVE_DELAY),
 				nsvc_timer_elapsed_ms(*nsvc));
 		/* stop Tns-alive and start Tns-test */
 		nsvc_start_timer(*nsvc, NSVC_TIMER_TNS_TEST);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 1148d6f..d72f34e 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1255,8 +1255,8 @@
 	log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
 	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
-	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_IN]);
-	rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_IN], msg->len);
+	rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_PKTS_IN));
+	rate_ctr_add(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BYTES_IN), msg->len);
 
 	if (msg->len < sizeof(struct gprs_ns_hdr)) {
 		rc = -EINVAL;
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 84f3784..7791094 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -347,7 +347,7 @@
 {
 	struct priv_bind *priv = bind->priv;
 	llist_add(&msg->list, &priv->backlog.list);
-	osmo_stat_item_inc(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
+	osmo_stat_item_inc(osmo_stat_item_group_get_item(bind->statg, NS2_BIND_STAT_BACKLOG_LEN), 1);
 	osmo_timer_schedule(&priv->backlog.timer, 0, priv->backlog.retry_us);
 }
 
@@ -355,7 +355,7 @@
 {
 	struct priv_bind *priv = bind->priv;
 	llist_add_tail(&msg->list, &priv->backlog.list);
-	osmo_stat_item_inc(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
+	osmo_stat_item_inc(osmo_stat_item_group_get_item(bind->statg, NS2_BIND_STAT_BACKLOG_LEN), 1);
 	osmo_timer_schedule(&priv->backlog.timer, 0, priv->backlog.retry_us);
 }
 
@@ -439,7 +439,7 @@
 			llist_add(&msg->list, &priv->backlog.list);
 			break;
 		}
-		osmo_stat_item_dec(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
+		osmo_stat_item_dec(osmo_stat_item_group_get_item(bind->statg, NS2_BIND_STAT_BACKLOG_LEN), 1);
 	}
 
 restart_timer:
diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c
index 93341bb..ad115ef 100644
--- a/src/gb/gprs_ns2_message.c
+++ b/src/gb/gprs_ns2_message.c
@@ -174,11 +174,11 @@
 
 	rc = nsvc->bind->send_vc(nsvc, msg);
 	if (rc < 0) {
-		rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT_DROP]);
-		rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT_DROP], bytes);
+		rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_PKTS_OUT_DROP));
+		rate_ctr_add(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BYTES_OUT_DROP), bytes);
 	} else {
-		rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
-		rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT], bytes);
+		rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_PKTS_OUT));
+		rate_ctr_add(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BYTES_OUT), bytes);
 	}
 
 	return rc;
@@ -223,7 +223,7 @@
 	if (!msg)
 		return -ENOMEM;
 
-	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_BLOCKED));
 
 	msg->l2h = msgb_put(msg, sizeof(*nsh));
 	nsh = (struct gprs_ns_hdr *) msg->l2h;
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 7ed8299..341a5a1 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -209,7 +209,7 @@
 
 	priv->alive.mode = NS_TOUT_TNS_TEST;
 	osmo_timer_schedule(&priv->alive.timer, nsi->timeout[NS_TOUT_TNS_TEST], 0);
-	osmo_stat_item_set(nsvc->statg->items[NS_STAT_ALIVE_DELAY],
+	osmo_stat_item_set(osmo_stat_item_group_get_item(nsvc->statg, NS_STAT_ALIVE_DELAY),
 		alive_timer_elapsed_ms(priv));
 }
 
@@ -229,7 +229,7 @@
 		osmo_timer_schedule(&priv->alive.timer, nsi->timeout[NS_TOUT_TNS_ALIVE], 0);
 		break;
 	case NS_TOUT_TNS_ALIVE:
-		rate_ctr_inc(&priv->nsvc->ctrg->ctr[NS_CTR_LOST_ALIVE]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(priv->nsvc->ctrg, NS_CTR_LOST_ALIVE));
 		priv->alive.N++;
 
 		if (priv->alive.N <= nsi->timeout[NS_TOUT_TNS_ALIVE_RETRIES]) {
@@ -335,7 +335,7 @@
 
 	if (old_state != GPRS_NS2_ST_BLOCKED) {
 		priv->N = 0;
-		rate_ctr_inc(&priv->nsvc->ctrg->ctr[NS_CTR_BLOCKED]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(priv->nsvc->ctrg, NS_CTR_BLOCKED));
 	}
 
 	if (priv->om_blocked) {
@@ -410,7 +410,7 @@
 	struct gprs_ns2_nse *nse = nsvc->nse;
 
 	if (old_state != GPRS_NS2_ST_UNBLOCKED)
-		rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_UNBLOCKED]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(nsvc->ctrg, NS_CTR_UNBLOCKED));
 
 	priv->accept_unitdata = true;
 	ns2_nse_notify_unblocked(nsvc, true);
@@ -525,7 +525,7 @@
 	switch (fi->state) {
 	case GPRS_NS2_ST_RESET:
 		if (priv->initiate_reset) {
-			rate_ctr_inc(&priv->nsvc->ctrg->ctr[NS_CTR_LOST_RESET]);
+			rate_ctr_inc(rate_ctr_group_get_ctr(priv->nsvc->ctrg, NS_CTR_LOST_RESET));
 			priv->N++;
 			if (priv->N <= nsi->timeout[NS_TOUT_TNS_RESET_RETRIES]) {
 				osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_RESET, nsi->timeout[NS_TOUT_TNS_RESET], 0);
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index 454a29e..6ced6a3 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -262,7 +262,7 @@
 	unsigned int i;
 
 	for (i = 0; i < ctrg->desc->num_ctr; i++) {
-		struct rate_ctr *ctr = &ctrg->ctr[i];
+		struct rate_ctr *ctr = rate_ctr_group_get_ctr(ctrg, i);
 		if (ctr->current && !strchr(ctrg->desc->ctr_desc[i].name, ':'))
 			fprintf(stream, " %s%s: %llu%s",
 				prefix, ctrg->desc->ctr_desc[i].description,
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index a4aedd3..15f50d2 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -110,130 +110,130 @@
 
 	sitem1 = osmo_stat_item_get_by_name(statg, "item.a");
 	OSMO_ASSERT(sitem1 != NULL);
-	OSMO_ASSERT(sitem1 == statg->items[TEST_A_ITEM]);
+	OSMO_ASSERT(sitem1 == osmo_stat_item_group_get_item(statg, TEST_A_ITEM));
 
 	sitem2 = osmo_stat_item_get_by_name(statg, "item.b");
 	OSMO_ASSERT(sitem2 != NULL);
 	OSMO_ASSERT(sitem2 != sitem1);
-	OSMO_ASSERT(sitem2 == statg->items[TEST_B_ITEM]);
+	OSMO_ASSERT(sitem2 == osmo_stat_item_group_get_item(statg, TEST_B_ITEM));
 
-	value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]);
+	value = osmo_stat_item_get_last(osmo_stat_item_group_get_item(statg, TEST_A_ITEM));
 	OSMO_ASSERT(value == -1);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 0);
 
-	osmo_stat_item_set(statg->items[TEST_A_ITEM], 1);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 1);
 
-	value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]);
+	value = osmo_stat_item_get_last(osmo_stat_item_group_get_item(statg, TEST_A_ITEM));
 	OSMO_ASSERT(value == 1);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 1);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 0);
 
 	for (i = 2; i <= 32; i++) {
-		osmo_stat_item_set(statg->items[TEST_A_ITEM], i);
-		osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), 1000 + i);
 
-		rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == i);
 
-		rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), &next_id_b, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == 1000 + i);
 	}
 
 	/* check if dec & inc is working */
-	osmo_stat_item_set(statg->items[TEST_A_ITEM], 42);
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 42);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 42);
 
-	osmo_stat_item_dec(statg->items[TEST_A_ITEM], 21);
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	osmo_stat_item_dec(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 21);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 21);
 
-	osmo_stat_item_inc(statg->items[TEST_A_ITEM], 21);
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	osmo_stat_item_inc(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 21);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 42);
 
 	/* Keep 2 in FIFO */
-	osmo_stat_item_set(statg->items[TEST_A_ITEM], 33);
-	osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + 33);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 33);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), 1000 + 33);
 
 	for (i = 34; i <= 64; i++) {
-		osmo_stat_item_set(statg->items[TEST_A_ITEM], i);
-		osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), 1000 + i);
 
-		rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == i-1);
 
-		rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), &next_id_b, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == 1000 + i-1);
 	}
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 64);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), &next_id_b, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 1000 + 64);
 
 	/* Overrun FIFOs */
 	for (i = 65; i <= 96; i++) {
-		osmo_stat_item_set(statg->items[TEST_A_ITEM], i);
-		osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), i);
+		osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), 1000 + i);
 	}
 
 	fprintf(stderr, "Skipping %d values\n", 93 - 65);
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 93 - 65 + 1);
 	OSMO_ASSERT(value == 93);
 
 	for (i = 94; i <= 96; i++) {
-		rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == i);
 	}
 
 	fprintf(stderr, "Skipping %d values\n", 90 - 65);
-	rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), &next_id_b, &value);
 	OSMO_ASSERT(rc == 90 - 65 + 1);
 	OSMO_ASSERT(value == 1000 + 90);
 
 	for (i = 91; i <= 96; i++) {
-		rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
+		rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_B_ITEM), &next_id_b, &value);
 		OSMO_ASSERT(rc == 1);
 		OSMO_ASSERT(value == 1000 + i);
 	}
 
 	/* Test Discard (single item) */
-	osmo_stat_item_set(statg->items[TEST_A_ITEM], 97);
-	rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 97);
+	rc = osmo_stat_item_discard(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a);
 	OSMO_ASSERT(rc == 1);
 
-	rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a);
+	rc = osmo_stat_item_discard(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a);
 	OSMO_ASSERT(rc == 0);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 0);
 
-	osmo_stat_item_set(statg->items[TEST_A_ITEM], 98);
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), 98);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 1);
 	OSMO_ASSERT(value == 98);
 
-	rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
+	rc = osmo_stat_item_get_next(osmo_stat_item_group_get_item(statg, TEST_A_ITEM), &next_id_a, &value);
 	OSMO_ASSERT(rc == 0);
 
 	osmo_stat_item_group_free(statg);
@@ -417,27 +417,27 @@
 	OSMO_ASSERT(send_count == 0);
 
 	fprintf(stderr, "report (group 1, counter 1 update):\n");
-	rate_ctr_inc(&ctrg1->ctr[TEST_A_CTR]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(ctrg1, TEST_A_CTR));
 	send_count = 0;
 	osmo_stats_report();
 	OSMO_ASSERT(send_count == 2);
 
 	fprintf(stderr, "report (group 1, item 1 update):\n");
-	osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
 	send_count = 0;
 	osmo_stats_report();
 	OSMO_ASSERT(send_count == 2);
 
 	fprintf(stderr, "report (group 1, item 1 update twice):\n");
-	osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10);
-	osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
 	send_count = 0;
 	osmo_stats_report();
 	OSMO_ASSERT(send_count == 2);
 
 	fprintf(stderr, "report (group 1, item 1 update twice, check max):\n");
-	osmo_stat_item_set(statg1->items[TEST_A_ITEM], 20);
-	osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 20);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
 	send_count = 0;
 	osmo_stats_report();
 	OSMO_ASSERT(send_count == 2);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24561
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I41297a8df68e28dfc6016330ac82b0ed5dd0ebc1
Gerrit-Change-Number: 24561
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210604/bda7c28f/attachment.htm>


More information about the gerrit-log mailing list