From 24b8c0ce9275c396581458c59c0d5f8db8ed9847 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 2 Jul 2020 14:59:16 +0200 Subject: [PATCH] mgcp_trunk: remove double check At the moment, the trunk prefix is checked twice. Lets re-arange the code a bit so that the check only happens once. Change-Id: I91fb8cf6e3b077ba8f18fdbcd071275c6fd7cacd Related: OS#2547 --- src/libosmo-mgcp/mgcp_trunk.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libosmo-mgcp/mgcp_trunk.c b/src/libosmo-mgcp/mgcp_trunk.c index e41ed0ee9..f3785cd30 100644 --- a/src/libosmo-mgcp/mgcp_trunk.c +++ b/src/libosmo-mgcp/mgcp_trunk.c @@ -159,13 +159,9 @@ struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char return mgcp_trunk_by_num(cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); } - prefix_len = sizeof(MGCP_ENDPOINT_PREFIX_E1_TRUNK) - 1; - if (strncmp(epname, MGCP_ENDPOINT_PREFIX_E1_TRUNK, prefix_len) == 0) { - trunk_nr = e1_trunk_nr_from_epname(epname); - if (trunk_nr < 0) - return NULL; + trunk_nr = e1_trunk_nr_from_epname(epname); + if (trunk_nr > 0) return mgcp_trunk_by_num(cfg, MGCP_TRUNK_E1, trunk_nr); - } /* Earlier versions of osmo-mgw were accepting endpoint names * without trunk prefix. This is normally not allowed, each MGCP