vty: simplify endpoint allocation
mgcp_parse_config() uses a helper function allocate_trunk() to
perform the trunk allocation. This helper function only calls
mgcp_endpoints_allocate() and checks the return code.
Call mgcp_endpoints_allocate() directly from mgcp_parse_config()
Change-Id: Iefdc5b905d76d2cd97f26584261fe5cbefb699cf
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 06420dd..9420d96 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -1269,18 +1269,6 @@
return 0;
}
-static int allocate_trunk(struct mgcp_trunk_config *trunk)
-{
- if (mgcp_endpoints_allocate(trunk) != 0) {
- LOGP(DLMGCP, LOGL_ERROR,
- "Failed to allocate %d endpoints on trunk %d.\n",
- trunk->number_endpoints, trunk->trunk_nr);
- return -1;
- }
-
- return 0;
-}
-
int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg,
enum mgcp_role role)
{
@@ -1304,17 +1292,18 @@
return -1;
}
- if (allocate_trunk(&g_cfg->trunk) != 0) {
+ if (mgcp_endpoints_allocate(&g_cfg->trunk) != 0) {
LOGP(DLMGCP, LOGL_ERROR,
- "Failed to initialize the virtual trunk.\n");
+ "Failed to initialize the virtual trunk (%d endpoints)\n",
+ g_cfg->trunk.number_endpoints);
return -1;
}
llist_for_each_entry(trunk, &g_cfg->trunks, entry) {
- if (allocate_trunk(trunk) != 0) {
+ if (mgcp_endpoints_allocate(trunk) != 0) {
LOGP(DLMGCP, LOGL_ERROR,
- "Failed to initialize E1 trunk %d.\n",
- trunk->trunk_nr);
+ "Failed to initialize trunk %d (%d endpoints)\n",
+ trunk->trunk_nr, trunk->number_endpoints);
return -1;
}
}