From: Zbigniew Jędrzejewski-Szmek Date: Mon, 30 Mar 2020 11:49:05 +0000 (+0200) Subject: sd-bus: simplify bus_maybe_reply_error X-Git-Tag: v246-rc1~651^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=934cf0a9c7b7f01f5a5aafb03bef4b7b5b0b14c3;p=thirdparty%2Fsystemd.git sd-bus: simplify bus_maybe_reply_error sd_bus_reply_method_errno already does the same two checks (sd_bus_error_is_set(error), r < 0) internally. But it did them in opposite order. The effect is the same, because sd_bus_reply_method_errno falls back to sd_bus_reply_method_error, but it seems inelegant. So let's simplify bus_maybe_reply_error() to offload the job fully to sd_bus_reply_method_errno(). No functional change. --- diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c index d5f8c6db647..5c3e955c20c 100644 --- a/src/libsystemd/sd-bus/bus-internal.c +++ b/src/libsystemd/sd-bus/bus-internal.c @@ -314,13 +314,9 @@ char *bus_address_escape(const char *v) { int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error) { assert(m); - if (r < 0) { + if (sd_bus_error_is_set(error) || r < 0) { if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL) sd_bus_reply_method_errno(m, r, error); - - } else if (sd_bus_error_is_set(error)) { - if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL) - sd_bus_reply_method_error(m, error); } else return r;