mgcp: Fix grammar, clean-up return codes

Mike's patch included clean-ups I want to apply separately and
change them a bit. If we return from an else we don't need to
put the else.

* Try the E1 trunk first
* Then try a local virtual trunk
* Fail if none of the above returned
This commit is contained in:
Holger Hans Peter Freyther 2015-09-04 16:01:12 +02:00
parent 79135acbb8
commit 614aba391d
1 changed files with 6 additions and 7 deletions

View File

@ -427,15 +427,14 @@ static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg, const char *
char *endptr = NULL;
unsigned int gw = INT_MAX;
if (strncmp(mgcp, "ds/e1", 5) == 0) {
if (strncmp(mgcp, "ds/e1", 5) == 0)
return find_e1_endpoint(cfg, mgcp);
} else {
gw = strtoul(mgcp, &endptr, 16);
if (gw > 0 && gw < cfg->trunk.number_endpoints && endptr[0] == '@')
return &cfg->trunk.endpoints[gw];
}
LOGP(DMGCP, LOGL_ERROR, "Not able to find endpoint: '%s'\n", mgcp);
gw = strtoul(mgcp, &endptr, 16);
if (gw > 0 && gw < cfg->trunk.number_endpoints && endptr[0] == '@')
return &cfg->trunk.endpoints[gw];
LOGP(DMGCP, LOGL_ERROR, "Not able to find the endpoint: '%s'\n", mgcp);
return NULL;
}