[MERGED] libosmo-abis[master]: Convert e1inp_{sign, ts}type_name() to use struct value_string

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Oct 16 22:14:50 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Convert e1inp_{sign,ts}type_name() to use struct value_string
......................................................................


Convert e1inp_{sign,ts}type_name() to use struct value_string

Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
---
M include/osmocom/abis/e1_input.h
M src/e1_input.c
2 files changed, 16 insertions(+), 15 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index c175649..8ef33d5 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -21,6 +21,7 @@
 	E1INP_SIGN_OSMO,	/* IPA CCM OSMO sub-type */
 };
 const char *e1inp_signtype_name(enum e1inp_sign_type tp);
+const struct value_string e1inp_sign_type_names[5];
 
 enum e1inp_ctr {
 	E1I_CTR_HDLC_ABORT,
@@ -65,6 +66,7 @@
 	E1INP_TS_TYPE_TRAU,
 };
 const char *e1inp_tstype_name(enum e1inp_ts_type tp);
+const struct value_string e1inp_ts_type_names[5];
 
 /* A timeslot in the E1 interface */
 struct e1inp_ts {
diff --git a/src/e1_input.c b/src/e1_input.c
index c9ae8e6..df990d5 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -200,30 +200,29 @@
 	write(pcap_fd, msg->l2h, msgb_l2len(msg));
 }
 
-static const char *sign_types[] = {
-	[E1INP_SIGN_NONE]	= "None",
-	[E1INP_SIGN_OML]	= "OML",
-	[E1INP_SIGN_RSL]	= "RSL",
-	[E1INP_SIGN_OSMO]	= "OSMO",
+const struct value_string e1inp_sign_type_names[5] = {
+	{ E1INP_SIGN_NONE,	"None" },
+	{ E1INP_SIGN_OML,	"OML" },
+	{ E1INP_SIGN_RSL,	"RSL" },
+	{ E1INP_SIGN_OSMO,	"OSMO" },
+	{ 0, NULL }
 };
+
 const char *e1inp_signtype_name(enum e1inp_sign_type tp)
 {
-	if (tp >= ARRAY_SIZE(sign_types))
-		return "undefined";
-	return sign_types[tp];
+	return get_value_string(e1inp_sign_type_names, tp);
 }
 
-static const char *ts_types[] = {
-	[E1INP_TS_TYPE_NONE]	= "None",
-	[E1INP_TS_TYPE_SIGN]	= "Signalling",
-	[E1INP_TS_TYPE_TRAU]	= "TRAU",
+const struct value_string e1inp_ts_type_names[5] = {
+	{ E1INP_TS_TYPE_NONE,	"None" },
+	{ E1INP_TS_TYPE_SIGN,	"Signalling" },
+	{ E1INP_TS_TYPE_TRAU,	"TRAU" },
+	{ 0, NULL }
 };
 
 const char *e1inp_tstype_name(enum e1inp_ts_type tp)
 {
-	if (tp >= ARRAY_SIZE(ts_types))
-		return "undefined";
-	return ts_types[tp];
+	return get_value_string(e1inp_ts_type_names, tp);
 }
 
 int abis_sendmsg(struct msgb *msg)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list