diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2015-03-16 10:00:32 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2015-03-16 10:01:07 +0100 |
commit | d74e904bf4bdd7f1d767a8db09987b90de809579 (patch) | |
tree | 07ab4f610c2f222a662daf417f1356154806c29e /src/print_ip_addr.c | |
parent | 6996f0a4a34e0744f09dbce39a2164c6fcee875e (diff) |
clang-format-3.5 -i **/*.[ch], update modeline
From here on, we’ll use clang-format to automatically format the source.
This has worked well in i3, so we are introducing it for i3status.
Diffstat (limited to 'src/print_ip_addr.c')
-rw-r--r-- | src/print_ip_addr.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/src/print_ip_addr.c b/src/print_ip_addr.c index 909a8b2..09b0992 100644 --- a/src/print_ip_addr.c +++ b/src/print_ip_addr.c @@ -1,4 +1,4 @@ -// vim:ts=8:expandtab +// vim:ts=4:sw=4:expandtab #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -18,50 +18,49 @@ * */ const char *get_ip_addr(const char *interface) { - static char part[512]; - socklen_t len = sizeof(struct sockaddr_in); - memset(part, 0, sizeof(part)); + static char part[512]; + socklen_t len = sizeof(struct sockaddr_in); + memset(part, 0, sizeof(part)); - struct ifaddrs *ifaddr, *addrp; - bool found = false; + struct ifaddrs *ifaddr, *addrp; + bool found = false; - getifaddrs(&ifaddr); + getifaddrs(&ifaddr); - if (ifaddr == NULL) - return NULL; + if (ifaddr == NULL) + return NULL; - /* Skip until we are at the AF_INET address of interface */ - for (addrp = ifaddr; + /* Skip until we are at the AF_INET address of interface */ + for (addrp = ifaddr; - (addrp != NULL && - (strcmp(addrp->ifa_name, interface) != 0 || - addrp->ifa_addr == NULL || - addrp->ifa_addr->sa_family != AF_INET)); + (addrp != NULL && + (strcmp(addrp->ifa_name, interface) != 0 || + addrp->ifa_addr == NULL || + addrp->ifa_addr->sa_family != AF_INET)); - addrp = addrp->ifa_next) { - /* Check if the interface is down */ - if (strcmp(addrp->ifa_name, interface) != 0) - continue; - found = true; - if ((addrp->ifa_flags & IFF_RUNNING) == 0) { - freeifaddrs(ifaddr); - return NULL; - } + addrp = addrp->ifa_next) { + /* Check if the interface is down */ + if (strcmp(addrp->ifa_name, interface) != 0) + continue; + found = true; + if ((addrp->ifa_flags & IFF_RUNNING) == 0) { + freeifaddrs(ifaddr); + return NULL; } + } - if (addrp == NULL) { - freeifaddrs(ifaddr); - return (found ? "no IP" : NULL); - } - - int ret; - if ((ret = getnameinfo(addrp->ifa_addr, len, part, sizeof(part), NULL, 0, NI_NUMERICHOST)) != 0) { - fprintf(stderr, "i3status: getnameinfo(): %s\n", gai_strerror(ret)); - freeifaddrs(ifaddr); - return "no IP"; - } + if (addrp == NULL) { + freeifaddrs(ifaddr); + return (found ? "no IP" : NULL); + } + int ret; + if ((ret = getnameinfo(addrp->ifa_addr, len, part, sizeof(part), NULL, 0, NI_NUMERICHOST)) != 0) { + fprintf(stderr, "i3status: getnameinfo(): %s\n", gai_strerror(ret)); freeifaddrs(ifaddr); - return part; -} + return "no IP"; + } + freeifaddrs(ifaddr); + return part; +} |