[PATCH] osmo-bsc[master]: Wrap channel state assignment in 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 Sep 6 16:23:45 UTC 2017


Hello Neels Hofmeyr, Jenkins Builder,

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

    https://gerrit.osmocom.org/3828

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

Wrap channel state assignment in macro

Previously we've used function so debug print always pointed to the same
place which is not very useful. Wrap it with macro so proper
file:line is printed. Also, make sure that we always change state only
through this wrapper and log only when the state has changed.

Change-Id: I21789f8021290965b61a54a2b23177ccbbfe8321
---
M include/osmocom/bsc/abis_rsl.h
M src/libbsc/abis_rsl.c
M src/libbsc/chan_alloc.c
3 files changed, 10 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/28/3828/4

diff --git a/include/osmocom/bsc/abis_rsl.h b/include/osmocom/bsc/abis_rsl.h
index f983fce..7bea79b 100644
--- a/include/osmocom/bsc/abis_rsl.h
+++ b/include/osmocom/bsc/abis_rsl.h
@@ -34,6 +34,9 @@
 
 #define GSM48_LEN2PLEN(a)	(((a) << 2) | 1)
 
+#define rsl_lchan_set_state(lch_, st_) \
+	rsl_lchan_set_state_with_log(lch_, st_, __BASE_FILE__, __LINE__)
+
 int rsl_bcch_info(const struct gsm_bts_trx *trx, enum osmo_sysinfo_type si_type, const uint8_t *data, int len);
 int rsl_sacch_filling(struct gsm_bts_trx *trx, uint8_t type,
 		      const uint8_t *data, int len);
@@ -74,7 +77,7 @@
 int rsl_release_request(struct gsm_lchan *lchan, uint8_t link_id,
 			enum rsl_rel_mode release_mode);
 
-int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
+int rsl_lchan_set_state_with_log(struct gsm_lchan *lchan, uint8_t state, const char *file, unsigned line);
 int rsl_lchan_mark_broken(struct gsm_lchan *lchan, const char *broken);
 
 /* to be provided by external code */
diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 09fb14b..51e4826 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -1225,11 +1225,12 @@
 	return 0;
 }
 
-int rsl_lchan_set_state(struct gsm_lchan *lchan, int state)
+int rsl_lchan_set_state_with_log(struct gsm_lchan *lchan, uint8_t state, const char *file, unsigned line)
 {
-	DEBUGP(DRSL, "%s state %s -> %s\n",
-	       gsm_lchan_name(lchan), gsm_lchans_name(lchan->state),
-	       gsm_lchans_name(state));
+	if (lchan->state != state)
+		LOGPSRC(DRSL, LOGL_DEBUG, file, line, "%s state %s -> %s\n",
+			gsm_lchan_name(lchan), gsm_lchans_name(lchan->state), gsm_lchans_name(state));
+
 	lchan->state = state;
 	return 0;
 }
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 679ad42..f0275bc 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -448,7 +448,7 @@
 	osmo_timer_del(&lchan->error_timer);
 
 	lchan->type = GSM_LCHAN_NONE;
-	lchan->state = LCHAN_S_NONE;
+	rsl_lchan_set_state(lchan, LCHAN_S_NONE);
 
 	if (lchan->abis_ip.rtp_socket) {
 		rtp_socket_free(lchan->abis_ip.rtp_socket);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I21789f8021290965b61a54a2b23177ccbbfe8321
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list