[PATCH] osmo-msc[master]: Fix VLR test macro

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
Wed Feb 7 15:30:02 UTC 2018


Hello daniel, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6296

to look at the new patch set (#5).

Fix VLR test macro

Previously EXPECT_ACCEPTED used parameter which wasn't explicitly passed
to it. This is potential source of bugs and makes code harder to read
and maintain. Fix this by adding the parameter.

While at it, also constify conn_exists() parameter.

Change-Id: I36ae1f9bb395921dc2c5a39e35fbb8040ba47213
Related: OS#2864
---
M tests/msc_vlr/msc_vlr_tests.c
M tests/msc_vlr/msc_vlr_tests.h
2 files changed, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/96/6296/5

diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index 556bf49..ed8cf1f 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -170,13 +170,18 @@
 		OSMO_ASSERT(gsup_tx_confirmed);
 }
 
-bool conn_exists(struct gsm_subscriber_connection *conn)
+bool conn_exists(const struct gsm_subscriber_connection *conn)
 {
 	struct gsm_subscriber_connection *c;
+
+	if (!conn)
+		return false;
+
 	llist_for_each_entry(c, &net->subscr_conns, entry) {
 		if (c == conn)
 			return true;
 	}
+
 	return false;
 }
 
@@ -210,7 +215,7 @@
 	    ran_type_name(rx_from_ran),
 	    gh_type_name(gh));
 
-	if (g_conn && !conn_exists(g_conn))
+	if (!conn_exists(g_conn))
 		g_conn = NULL;
 
 	if (!g_conn) {
@@ -232,7 +237,7 @@
 			msc_dtap(g_conn, 23, msg);
 	}
 
-	if (g_conn && !conn_exists(g_conn))
+	if (!conn_exists(g_conn))
 		g_conn = NULL;
 }
 
diff --git a/tests/msc_vlr/msc_vlr_tests.h b/tests/msc_vlr/msc_vlr_tests.h
index d00eb9f..49d7bab 100644
--- a/tests/msc_vlr/msc_vlr_tests.h
+++ b/tests/msc_vlr/msc_vlr_tests.h
@@ -144,14 +144,14 @@
 
 void thwart_rx_non_initial_requests();
 
-#define EXPECT_ACCEPTED(expect_accepted) do { \
-		if (g_conn) \
-			OSMO_ASSERT(conn_exists(g_conn)); \
-		bool accepted = msc_subscr_conn_is_accepted(g_conn); \
+#define EXPECT_ACCEPTED(expect_accepted, x_conn) do {	\
+		if (x_conn) \
+			OSMO_ASSERT(conn_exists(x_conn)); \
+		bool accepted = msc_subscr_conn_is_accepted(x_conn); \
 		fprintf(stderr, "msc_subscr_conn_is_accepted() == %s\n", \
 			accepted ? "true" : "false"); \
 		OSMO_ASSERT(accepted == expect_accepted); \
-	} while (false)
+	} while (0)
 
 #define VERBOSE_ASSERT(val, expect_op, fmt) \
 	do { \

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I36ae1f9bb395921dc2c5a39e35fbb8040ba47213
Gerrit-PatchSet: 5
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>



More information about the gerrit-log mailing list