Change in osmo-ttcn3-hacks[master]: fixup for Osmocom_CTRL_Functions: rate counters in bulk

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/.

neels gerrit-no-reply at lists.osmocom.org
Tue Jun 30 03:12:15 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/19061 )


Change subject: fixup for Osmocom_CTRL_Functions: rate counters in bulk
......................................................................

fixup for Osmocom_CTRL_Functions: rate counters in bulk

At the time of writing Ief0d9b096feeee7d37b5f2429dd3e80de0161806 I wasn't aware
of the 'inout' keyword, which allows to pass the counter list by reference.

Rather modify the counter lists in-place. Instead of requiring

  list := f_counter_name_vals_add(list, ...)

rather implement by directly modifying list:

  f_counter_name_vals_add(list, ...)

Change-Id: I85ac56b042fe4bb1db392c1f451c8e900582cc2a
---
M bsc/BSC_Tests.ttcn
M library/Osmocom_CTRL_Functions.ttcn
2 files changed, 7 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/61/19061/1

diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index facb001..f25c75d 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -197,7 +197,7 @@
 }
 
 private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
-	g_ctr_msc := f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
+	f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
 }
 
 /*  f_ctrs_msc_init();
diff --git a/library/Osmocom_CTRL_Functions.ttcn b/library/Osmocom_CTRL_Functions.ttcn
index ee7025c..60c66c0 100644
--- a/library/Osmocom_CTRL_Functions.ttcn
+++ b/library/Osmocom_CTRL_Functions.ttcn
@@ -222,12 +222,12 @@
 	}
 
 	/* In a list of one instance's counters, increment a specifically named counter. */
-	function f_counter_name_vals_add(CounterNameVals vals, charstring countername, integer val := 1)
-	return CounterNameVals{
+	function f_counter_name_vals_add(inout CounterNameVals vals, charstring countername, integer val := 1)
+	{
 		for (var integer i := 0; i < lengthof(vals); i := i + 1) {
 			if (vals[i].name == countername) {
 				vals[i].val := vals[i].val + val;
-				return vals;
+				return;
 			}
 		}
 		/* name not found, append */
@@ -235,15 +235,13 @@
 			name := countername,
 			val := val
 		}
-		return vals;
 	}
 
 	/* In a list of several instances' counters, increment a specific instance's specifically named counter. */
-	function f_counter_name_vals_list_add(CounterNameValsList vals, integer instance_nr,
+	function f_counter_name_vals_list_add(inout CounterNameValsList vals, integer instance_nr,
 	                                      charstring countername, integer val := 1)
-	return CounterNameValsList {
-		vals[instance_nr] := f_counter_name_vals_add(vals[instance_nr], countername, val);
-		return vals;
+	{
+		f_counter_name_vals_add(vals[instance_nr], countername, val);
 	}
 
 	/* For a specific instance, call f_counter_name_vals_get() and compare with expected counter values.

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/19061
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I85ac56b042fe4bb1db392c1f451c8e900582cc2a
Gerrit-Change-Number: 19061
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200630/cb9c9cff/attachment.htm>


More information about the gerrit-log mailing list