Change in libosmocore[master]: gprs_ns2_sns: refactor ip4_weight_sum/ip6_weight_sum

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Sun Jun 6 21:38:45 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24587 )


Change subject: gprs_ns2_sns: refactor ip4_weight_sum/ip6_weight_sum
......................................................................

gprs_ns2_sns: refactor ip4_weight_sum/ip6_weight_sum

Use the new introduced struct ns2_sns_elems instead of
the elems seperate.

Related: OS#5036
Change-Id: I0956ab6085554210569188f52cae121e32fca19b
---
M src/gb/gprs_ns2_sns.c
1 file changed, 14 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/24587/1

diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index 2e84d16..66765f3 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -176,45 +176,43 @@
 }
 
 /* helper function to compute the sum of all (data or signaling) weights */
-static int ip4_weight_sum(const struct gprs_ns_ie_ip4_elem *ip4, unsigned int num,
-			  bool data_weight)
+static int ip4_weight_sum(const struct ns2_sns_elems *elems, bool data_weight)
 {
 	unsigned int i;
 	int weight_sum = 0;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < elems->num_ip4; i++) {
 		if (data_weight)
-			weight_sum += ip4[i].data_weight;
+			weight_sum += elems->ip4[i].data_weight;
 		else
-			weight_sum += ip4[i].sig_weight;
+			weight_sum += elems->ip4[i].sig_weight;
 	}
 	return weight_sum;
 }
-#define ip4_weight_sum_data(x,y)	ip4_weight_sum(x, y, true)
-#define ip4_weight_sum_sig(x,y)		ip4_weight_sum(x, y, false)
+#define ip4_weight_sum_data(elems)		ip4_weight_sum(elems, true)
+#define ip4_weight_sum_sig(elems)		ip4_weight_sum(elems, false)
 
 /* helper function to compute the sum of all (data or signaling) weights */
-static int ip6_weight_sum(const struct gprs_ns_ie_ip6_elem *ip6, unsigned int num,
-			  bool data_weight)
+static int ip6_weight_sum(const struct ns2_sns_elems *elems, bool data_weight)
 {
 	unsigned int i;
 	int weight_sum = 0;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < elems->num_ip6; i++) {
 		if (data_weight)
-			weight_sum += ip6[i].data_weight;
+			weight_sum += elems->ip6[i].data_weight;
 		else
-			weight_sum += ip6[i].sig_weight;
+			weight_sum += elems->ip6[i].sig_weight;
 	}
 	return weight_sum;
 }
-#define ip6_weight_sum_data(x,y)	ip6_weight_sum(x, y, true)
-#define ip6_weight_sum_sig(x,y)		ip6_weight_sum(x, y, false)
+#define ip6_weight_sum_data(elems)		ip6_weight_sum(elems, true)
+#define ip6_weight_sum_sig(elems)		ip6_weight_sum(elems, false)
 
 static int nss_weight_sum(const struct ns2_sns_state *nss, bool data_weight)
 {
-	return ip4_weight_sum(nss->remote.ip4, nss->remote.num_ip4, data_weight) +
-	       ip6_weight_sum(nss->remote.ip6, nss->remote.num_ip6, data_weight);
+	return ip4_weight_sum(&nss->remote, data_weight) +
+	       ip6_weight_sum(&nss->remote, data_weight);
 }
 #define nss_weight_sum_data(nss)	nss_weight_sum(nss, true)
 #define nss_weight_sum_sig(nss)		nss_weight_sum(nss, false)

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0956ab6085554210569188f52cae121e32fca19b
Gerrit-Change-Number: 24587
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210606/71a72795/attachment.htm>


More information about the gerrit-log mailing list