diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-06-02 09:38:41 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-06-02 09:51:32 +0200 |
commit | 0958938d4ea32b4eff288b4b1369384f8eaddb93 (patch) | |
tree | deba35949b9ec3f9f2e9f5b4109cd0dec742797c /openbsc/src/gprs | |
parent | f2e114ac85700c8b018d4d1495f6ef1762e0718d (diff) |
sgsn: Simplify finding/using the first address of the result
The loop was used to print all returned addresses but we can
simply pick the first one. This is fixing a coverity issue that
the loop will be executed eaxactly once (and that was on
purpose).
Simplify the code and just take the first element (which might
be NULL).
Fixes: Coverity CID#1302852
Diffstat (limited to 'openbsc/src/gprs')
-rw-r--r-- | openbsc/src/gprs/gprs_gmm.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 04f75cfe4..0e7543031 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -1658,7 +1658,6 @@ static void ggsn_lookup_cb(void *arg, int status, int timeouts, struct hostent * struct sgsn_ggsn_ctx *ggsn; struct sgsn_ggsn_lookup *lookup = arg; struct in_addr *addr = NULL; - int i; /* The context is gone while we made a request */ if (!lookup->mmctx) { @@ -1700,12 +1699,8 @@ static void ggsn_lookup_cb(void *arg, int status, int timeouts, struct hostent * goto reject_due_failure; } - /* get the address */ - for (i = 0, addr = (struct in_addr *) hostent->h_addr_list[i]; addr; - i++, addr = (struct in_addr *) hostent->h_addr_list[i]) { - break; - } - + /* Get the first addr from the list */ + addr = (struct in_addr *) hostent->h_addr_list[0]; if (!addr) { LOGMMCTXP(LOGL_ERROR, lookup->mmctx, "No host address.\n"); goto reject_due_failure; |