summaryrefslogtreecommitdiffstats
path: root/libxtables
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@inai.de>2017-03-08 17:26:56 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2017-03-08 17:48:51 +0100
commit9f50bbdfee7e5f16ac84fb7f7605f9cdce82062a (patch)
tree40e4a0292e828dcd6b74375bd51dda15473e0fef /libxtables
parentc6df55d6ebbe6102ac5136ae38813bea42d8c782 (diff)
libxtables: remove unnecessary nesting from host_to_ip(6)addr
The error path already terminally returns from the function, so there is no point in having an explicit else block. Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'libxtables')
-rw-r--r--libxtables/xtables.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index d43f9706..ae73a06a 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1372,21 +1372,18 @@ static struct in_addr *host_to_ipaddr(const char *name, unsigned int *naddr)
hints.ai_socktype = SOCK_RAW;
*naddr = 0;
- if ((err = getaddrinfo(name, NULL, &hints, &res)) != 0) {
+ err = getaddrinfo(name, NULL, &hints, &res);
+ if (err != 0)
return NULL;
- } else {
- for (p = res; p != NULL; p = p->ai_next)
- ++*naddr;
- addr = xtables_calloc(*naddr, sizeof(struct in_addr));
- for (i = 0, p = res; p != NULL; p = p->ai_next)
- memcpy(&addr[i++],
- &((const struct sockaddr_in *)p->ai_addr)->sin_addr,
- sizeof(struct in_addr));
- freeaddrinfo(res);
- return addr;
- }
-
- return NULL;
+ for (p = res; p != NULL; p = p->ai_next)
+ ++*naddr;
+ addr = xtables_calloc(*naddr, sizeof(struct in_addr));
+ for (i = 0, p = res; p != NULL; p = p->ai_next)
+ memcpy(&addr[i++],
+ &((const struct sockaddr_in *)p->ai_addr)->sin_addr,
+ sizeof(struct in_addr));
+ freeaddrinfo(res);
+ return addr;
}
static struct in_addr *
@@ -1662,23 +1659,20 @@ host_to_ip6addr(const char *name, unsigned int *naddr)
hints.ai_socktype = SOCK_RAW;
*naddr = 0;
- if ((err = getaddrinfo(name, NULL, &hints, &res)) != 0) {
+ err = getaddrinfo(name, NULL, &hints, &res);
+ if (err != 0)
return NULL;
- } else {
- /* Find length of address chain */
- for (p = res; p != NULL; p = p->ai_next)
- ++*naddr;
- /* Copy each element of the address chain */
- addr = xtables_calloc(*naddr, sizeof(struct in6_addr));
- for (i = 0, p = res; p != NULL; p = p->ai_next)
- memcpy(&addr[i++],
- &((const struct sockaddr_in6 *)p->ai_addr)->sin6_addr,
- sizeof(struct in6_addr));
- freeaddrinfo(res);
- return addr;
- }
-
- return NULL;
+ /* Find length of address chain */
+ for (p = res; p != NULL; p = p->ai_next)
+ ++*naddr;
+ /* Copy each element of the address chain */
+ addr = xtables_calloc(*naddr, sizeof(struct in6_addr));
+ for (i = 0, p = res; p != NULL; p = p->ai_next)
+ memcpy(&addr[i++],
+ &((const struct sockaddr_in6 *)p->ai_addr)->sin6_addr,
+ sizeof(struct in6_addr));
+ freeaddrinfo(res);
+ return addr;
}
static struct in6_addr *network_to_ip6addr(const char *name)