From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jun 2025 14:23:31 +0000 (+0200) Subject: shared/bus-unit-util: define helper for SuccessActionExitStatus= and friend X-Git-Tag: v258-rc1~183^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9806468ea41e0ff002b610d5cdb6d6aeb9d7cb33;p=thirdparty%2Fsystemd.git shared/bus-unit-util: define helper for SuccessActionExitStatus= and friend --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 1cd10632226..bb499824577 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -2169,6 +2169,26 @@ static int bus_append_exit_status(sd_bus_message *m, const char *field, const ch return 1; } +static int bus_append_action_exit_status(sd_bus_message *m, const char *field, const char *eq) { + int r; + + if (isempty(eq)) + r = sd_bus_message_append(m, "(sv)", field, "i", -1); + else { + uint8_t u; + + r = safe_atou8(eq, &u); + if (r < 0) + return log_error_errno(r, "Failed to parse %s=%s", field, eq); + + r = sd_bus_message_append(m, "(sv)", field, "i", (int) u); + } + if (r < 0) + return bus_log_create_error(r); + + return 1; +} + static int bus_append_listen(sd_bus_message *m, const char *field, const char *eq) { int r; @@ -2902,23 +2922,8 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const return bus_append_safe_atou(m, field, eq); if (STR_IN_SET(field, "SuccessActionExitStatus", - "FailureActionExitStatus")) { - if (isempty(eq)) - r = sd_bus_message_append(m, "(sv)", field, "i", -1); - else { - uint8_t u; - - r = safe_atou8(eq, &u); - if (r < 0) - return log_error_errno(r, "Failed to parse %s=%s", field, eq); - - r = sd_bus_message_append(m, "(sv)", field, "i", (int) u); - } - if (r < 0) - return bus_log_create_error(r); - - return 1; - } + "FailureActionExitStatus")) + return bus_append_action_exit_status(m, field, eq); if (unit_dependency_from_string(field) >= 0 || STR_IN_SET(field, "Documentation",