diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-24 19:45:16 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-31 14:36:12 -0400 |
commit | e62d8c3944745ed276e6d4f33153009860e5cfc5 (patch) | |
tree | e7f70ed3b80581017b6340723ab6f1d6b9c30bad /src/core/loopback-setup.c | |
parent | 3c8bed4ee061f96acb4d70a591a9849bddd2a659 (diff) |
Modernization
Use _cleanup_ and wrap lines to ~80 chars and such.
Diffstat (limited to 'src/core/loopback-setup.c')
-rw-r--r-- | src/core/loopback-setup.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index 065b75a6e3..bfd0d93204 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -229,7 +229,8 @@ static int read_response(int fd, unsigned requests_max) { } static int check_loopback(void) { - int r, fd; + int r; + int _cleanup_close_ fd; union { struct sockaddr sa; struct sockaddr_in in; @@ -251,8 +252,6 @@ static int check_loopback(void) { else r = errno == EADDRNOTAVAIL ? 0 : -errno; - close_nointr_nofail(fd); - return r; } @@ -263,7 +262,7 @@ int loopback_setup(void) { struct sockaddr_nl nl; } sa; unsigned requests = 0, i; - int fd; + int _cleanup_close_ fd = -1; bool eperm = false; errno = 0; @@ -279,16 +278,16 @@ int loopback_setup(void) { sa.nl.nl_family = AF_NETLINK; if (bind(fd, &sa.sa, sizeof(sa)) < 0) { r = -errno; - goto finish; + goto error; } r = add_adresses(fd, if_loopback, &requests); if (r < 0) - goto finish; + goto error; r = start_interface(fd, if_loopback, &requests); if (r < 0) - goto finish; + goto error; for (i = 0; i < requests; i++) { r = read_response(fd, requests); @@ -296,22 +295,17 @@ int loopback_setup(void) { if (r == -EPERM) eperm = true; else if (r < 0) - goto finish; + goto error; } if (eperm && check_loopback() < 0) { r = -EPERM; - goto finish; + goto error; } - r = 0; - -finish: - if (r < 0) - log_warning("Failed to configure loopback device: %s", strerror(-r)); - - if (fd >= 0) - close_nointr_nofail(fd); + return 0; +error: + log_warning("Failed to configure loopback device: %s", strerror(-r)); return r; } |