]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: fix negated boolean function
authorLennart Poettering <lennart@poettering.net>
Wed, 15 Jun 2016 20:35:23 +0000 (22:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Jun 2016 11:20:48 +0000 (13:20 +0200)
It's weird having a "negative" function link_is_unmanaged(), let's invert it
and get rid of the negation this way, by renaming it to link_is_managed().

Internally we stored this as a positive boolean already, hence let's do this
for the function too.

src/resolve/resolved-link.c

index 8cfaacafffd74fab60e3827ea522a1e24188b3df..b321aefda9e65b3925f8f5b04da9901025cdc0bb 100644 (file)
@@ -447,7 +447,7 @@ clear:
         return r;
 }
 
-static int link_is_unmanaged(Link *l) {
+static int link_is_managed(Link *l) {
         _cleanup_free_ char *state = NULL;
         int r;
 
@@ -455,11 +455,11 @@ static int link_is_unmanaged(Link *l) {
 
         r = sd_network_link_get_setup_state(l->ifindex, &state);
         if (r == -ENODATA)
-                return 1;
+                return 0;
         if (r < 0)
                 return r;
 
-        return STR_IN_SET(state, "pending", "unmanaged");
+        return !STR_IN_SET(state, "pending", "unmanaged");
 }
 
 static void link_read_settings(Link *l) {
@@ -469,12 +469,12 @@ static void link_read_settings(Link *l) {
 
         /* Read settings from networkd, except when networkd is not managing this interface. */
 
-        r = link_is_unmanaged(l);
+        r = link_is_managed(l);
         if (r < 0) {
                 log_warning_errno(r, "Failed to determine whether interface %s is managed: %m", l->name);
                 return;
         }
-        if (r > 0) {
+        if (r == 0) {
 
                 /* If this link used to be managed, but is now unmanaged, flush all our settings — but only once. */
                 if (l->is_managed)