From 780896a4f1ec7e36c8f72c866ba9693d790f9741 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Nov 2013 04:01:46 +0100 Subject: bus: rework sd_bus_error APIs All calls that set a sd_bus_error structure will now return the same error converted to a negative errno. This may be used as syntactic sugar to return from a function and setting a bus_error structure in one go. Also, translate all Linux Exyz (EIO, EINVAL, EUCLEAN, EPIPE, ...) automatically into counterparts in the (new) "Posix.Error." namespace. If we fail to allocate memory for the components of a sd_bus_error automatically reset it to an OOM error which we always can write. --- src/libsystemd-bus/bus-message.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/libsystemd-bus/bus-message.c') diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index 538a28af9e..132426f6fd 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -624,18 +624,14 @@ _public_ int sd_bus_message_new_method_errorf( _cleanup_free_ sd_bus_error error = SD_BUS_ERROR_NULL; va_list ap; - int r; assert_return(name, -EINVAL); assert_return(m, -EINVAL); va_start(ap, format); - r = bus_error_setfv(&error, name, format, ap); + bus_error_setfv(&error, name, format, ap); va_end(ap); - if (r < 0) - return r; - return sd_bus_message_new_method_error(call, &error, m); } @@ -664,15 +660,11 @@ _public_ int sd_bus_message_new_method_errnof( _cleanup_free_ sd_bus_error berror = SD_BUS_ERROR_NULL; va_list ap; - int r; va_start(ap, format); - r = bus_error_set_errnofv(&berror, error, format, ap); + bus_error_set_errnofv(&berror, error, format, ap); va_end(ap); - if (r < 0) - return r; - return sd_bus_message_new_method_error(call, &berror, m); } -- cgit v1.2.3-54-g00ecf