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

Thomas H.P. Andersen phomes at kemper.freedesktop.org
Tue Sep 16 12:31:22 PDT 2014


 src/libsystemd-terminal/sysview.c   |    6 +++---
 src/libsystemd/sd-bus/bus-message.c |    2 +-
 src/libsystemd/sd-bus/sd-bus.c      |    2 --
 src/network/networkd-link.c         |    2 --
 4 files changed, 4 insertions(+), 8 deletions(-)

New commits:
commit 9169b9a8cc43046f92a4c5c85b0b3fe9ca0fb429
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date:   Mon Sep 15 22:55:36 2014 +0200

    terminal: sd_bus_error_get_errno returns positive errno
    
    The 3 calls to sd_bus_error_get_errno appear to expect a negative
    return value.
    
    This patch negates the returned value so it matches the other error
    cases in the 3 functions where sd_bus_error_get_errno is used.

diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
index 2083f5a..fde87d1 100644
--- a/src/libsystemd-terminal/sysview.c
+++ b/src/libsystemd-terminal/sysview.c
@@ -263,7 +263,7 @@ static int session_take_control_fn(sd_bus *bus,
 
                 log_debug("sysview: %s: TakeControl failed: %s: %s",
                           session->name, e->name, e->message);
-                error = sd_bus_error_get_errno(e);
+                error = -sd_bus_error_get_errno(e);
         } else {
                 session->has_control = true;
                 error = 0;
@@ -1195,7 +1195,7 @@ static int context_ld_list_seats_fn(sd_bus *bus,
 
                 log_debug("sysview: ListSeats on logind failed: %s: %s",
                           error->name, error->message);
-                return sd_bus_error_get_errno(error);
+                return -sd_bus_error_get_errno(error);
         }
 
         r = sd_bus_message_enter_container(reply, 'a', "(so)");
@@ -1247,7 +1247,7 @@ static int context_ld_list_sessions_fn(sd_bus *bus,
 
                 log_debug("sysview: ListSessions on logind failed: %s: %s",
                           error->name, error->message);
-                return sd_bus_error_get_errno(error);
+                return -sd_bus_error_get_errno(error);
         }
 
         r = sd_bus_message_enter_container(reply, 'a', "(susso)");

commit b49ffb29ed902f173852707652b3e3c9c303cebb
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date:   Mon Sep 15 22:36:43 2014 +0200

    sd-bus: sd_bus_message_get_errno should only return positive errno
    
    sd_bus_message_get_errno can currently return either a number of
    different poitive errno values (from bus-error-mapping), or a negative
    EINVAL if passed null as parameter.
    
    The check for null parameter was introduced in 40ca29a1370379d43e44c0ed425eecc7218dcbca
    at the same as the function was renamed from bus_message_to_errno and
    made public API. Before becoming public the function used to return
    only negative values.
    
    It is weird to have a function return both positive and negative errno
    and it generally looks like a mistake. The function is guarded by the
    --enable-kdbus flags so I wonder if we still have time to fix it up?
    It does not have any documentation yet. However, except for a few details
    it is just a convenient way to call sd_bus_error_get_errno which is documented
    to return only positive errno.
    
    This patch makes it return only positive errno and fixes up the two
    calls to the function that tried to cope with both positive and negative
    values.

diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index bfb14fc..1fa3ad2 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5337,7 +5337,7 @@ int bus_header_message_size(struct bus_header *h, size_t *sum) {
 }
 
 _public_ int sd_bus_message_get_errno(sd_bus_message *m) {
-        assert_return(m, -EINVAL);
+        assert_return(m, EINVAL);
 
         if (m->header->type != SD_BUS_MESSAGE_METHOD_ERROR)
                 return 0;
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 33b65ab..28b993b 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -349,8 +349,6 @@ static int hello_callback(sd_bus *bus, sd_bus_message *reply, void *userdata, sd
         assert(reply);
 
         r = sd_bus_message_get_errno(reply);
-        if (r < 0)
-                return r;
         if (r > 0)
                 return -r;
 
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9bf1a81..427f695 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -725,8 +725,6 @@ static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata,
                 return 1;
 
         r = sd_bus_message_get_errno(m);
-        if (r < 0)
-                r = -r;
         if (r > 0)
                 log_warning_link(link, "Could not set hostname: %s",
                                  strerror(r));



More information about the systemd-commits mailing list