[systemd-commits] 2 commits - src/network src/systemd

Tom Gundersen tomegun at kemper.freedesktop.org
Thu Feb 27 17:07:47 PST 2014


 src/network/networkd-wait-online.c |   15 +++++----------
 src/network/sd-network.c           |   23 ++++++++++-------------
 src/systemd/sd-network.h           |    4 ++--
 3 files changed, 17 insertions(+), 25 deletions(-)

New commits:
commit cb6fa44cb5411ed574f14109ee862ff663ab0a36
Author: Tom Gundersen <teg at jklm.no>
Date:   Fri Feb 28 02:07:29 2014 +0100

    sd-network: turn states 'unknown' and 'unmanaged' into errnos

diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c
index 900dc05..51c6bbd 100644
--- a/src/network/networkd-wait-online.c
+++ b/src/network/networkd-wait-online.c
@@ -38,20 +38,15 @@ static bool all_configured(void) {
                 _cleanup_free_ char *state = NULL;
 
                 r = sd_network_get_link_state(indices[i], &state);
-                if (r < 0)
+                if (r == -EUNATCH)
+                        continue;
+                if (r < 0 || !streq(state, "configured"))
                         return false;
 
-                if (streq(state, "configured"))
-                        one_ready = true;
-
-                if (!streq(state, "configured") && !streq(state, "unmanaged"))
-                        return false;
+                one_ready = true;
         }
 
-        if (one_ready)
-                return true;
-
-        return false;
+        return one_ready;
 }
 
 static int event_handler(sd_event_source *s, int fd, uint32_t revents,
diff --git a/src/network/sd-network.c b/src/network/sd-network.c
index 7469873..23af940 100644
--- a/src/network/sd-network.c
+++ b/src/network/sd-network.c
@@ -34,7 +34,7 @@
 #include "dhcp-lease-internal.h"
 
 _public_ int sd_network_get_link_state(unsigned index, char **state) {
-        char *p, *s = NULL;
+        _cleanup_free_ char *s = NULL, *p = NULL;
         int r;
 
         assert_return(index, -EINVAL);
@@ -44,23 +44,20 @@ _public_ int sd_network_get_link_state(unsigned index, char **state) {
                 return -ENOMEM;
 
         r = parse_env_file(p, NEWLINE, "STATE", &s, NULL);
-        free(p);
-
-        if (r == -ENOENT) {
-                free(s);
-                s = strdup("unknown");
-                if (!s)
-                        return -ENOMEM;
 
-                *state = s;
-                return 0;
-        } else if (r < 0) {
-                free(s);
+        if (r == -ENOENT)
+                return -ENODATA;
+        else if (r < 0)
                 return r;
-        } else if (!s)
+        else if (!s)
                 return -EIO;
 
+        if (streq(s, "unmanaged"))
+                return -EUNATCH;
+
         *state = s;
+        s = NULL;
+
         return 0;
 }
 

commit 82bdf8ce36ccfe1b6ff389a9c9c7e2b2d049a43d
Author: Tom Gundersen <teg at jklm.no>
Date:   Fri Feb 28 01:49:41 2014 +0100

    sd-network: fix header

diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index c0b093d..984527f 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -1,7 +1,7 @@
 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
-#ifndef foosdloginhfoo
-#define foosdloginhfoo
+#ifndef foosdnetworkhfoo
+#define foosdnetworkhfoo
 
 /***
   This file is part of systemd.



More information about the systemd-commits mailing list