[systemd-devel] [PATCH 02/11] libsystemd-dhcp: Return proper error if bind fails

Patrik Flykt patrik.flykt at linux.intel.com
Fri Dec 20 07:16:11 PST 2013


This also fixes a minor indentation damage.
---
 src/libsystemd-dhcp/dhcp-network.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd-dhcp/dhcp-network.c b/src/libsystemd-dhcp/dhcp-network.c
index 83a3084..3ff2d0b 100644
--- a/src/libsystemd-dhcp/dhcp-network.c
+++ b/src/libsystemd-dhcp/dhcp-network.c
@@ -31,8 +31,8 @@
 #include "dhcp-internal.h"
 
 int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
- {
-        int s;
+{
+        int s, err;
 
         s = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
                    htons(ETH_P_IP));
@@ -46,8 +46,9 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
         memset(link->ll.sll_addr, 0xff, ETH_ALEN);
 
         if (bind(s, &link->sa, sizeof(link->ll)) < 0) {
+                err = -errno;
                 close(s);
-                return -errno;
+                return err;
         }
 
         return s;
-- 
1.7.10.4



More information about the systemd-devel mailing list