diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2010-04-06 14:52:13 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2010-04-06 14:55:22 +0200 |
commit | c645340b1d90b50270f831f4e48dfde4b4e47278 (patch) | |
tree | 1ee71f88f378e051b3e1316a1a3434438ff0fb6b /src/print_ipv6_addr.c | |
parent | 706498644cbc7a6953aee3dd2eb4777c66c471b7 (diff) |
Little style fixes for the last commit
Diffstat (limited to 'src/print_ipv6_addr.c')
-rw-r--r-- | src/print_ipv6_addr.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/print_ipv6_addr.c b/src/print_ipv6_addr.c index bfd985d..b370011 100644 --- a/src/print_ipv6_addr.c +++ b/src/print_ipv6_addr.c @@ -9,7 +9,7 @@ #include <string.h> #include <arpa/inet.h> -static char * get_sockname(struct addrinfo *addr) { +static char *get_sockname(struct addrinfo *addr) { static char buf[INET6_ADDRSTRLEN+1]; struct sockaddr_storage local; int ret; @@ -34,7 +34,6 @@ static char * get_sockname(struct addrinfo *addr) { return NULL; } - socklen_t local_len = sizeof(struct sockaddr_storage); if (getsockname(fd, (struct sockaddr*)&local, &local_len) == -1) { perror("getsockname()"); @@ -105,21 +104,22 @@ static char *get_ipv6_addr() { void print_ipv6_info(const char *format_up, const char *format_down) { const char *walk; - char * addr_string = get_ipv6_addr(); - + char *addr_string = get_ipv6_addr(); + if (addr_string == NULL) { printf("%s", format_down); - } else { - for (walk = format_up; *walk != '\0'; walk++) { - if (*walk != '%') { - putchar(*walk); - continue; - } - - if (strncmp(walk+1, "ip", strlen("ip")) == 0) { - printf("%s", addr_string); - walk += strlen("ip"); - } + return; + } + + for (walk = format_up; *walk != '\0'; walk++) { + if (*walk != '%') { + putchar(*walk); + continue; + } + + if (strncmp(walk+1, "ip", strlen("ip")) == 0) { + printf("%s", addr_string); + walk += strlen("ip"); } } } |