From: David Tardon Date: Tue, 11 Apr 2023 15:25:42 +0000 (+0200) Subject: tree-wide: drop unneeded output params X-Git-Tag: v254-rc1~750^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e891cbb5cfb0de54588988f1c9969244a9317a3;p=thirdparty%2Fsystemd.git tree-wide: drop unneeded output params Neither of the callers of bus_deserialize_and_dump_unit_file_changes() touches the changes array, so let's simplify things and keep it internal to the function. --- diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 10bb8cc8efd..353b3394948 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1755,15 +1755,11 @@ static int start_machine(int argc, char *argv[], void *userdata) { static int enable_machine(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; - InstallChange *changes = NULL; - size_t n_changes = 0; const char *method; sd_bus *bus = ASSERT_PTR(userdata); int r; bool enable; - CLEANUP_ARRAY(changes, n_changes, install_changes_free); - polkit_agent_open_if_enabled(arg_transport, arg_ask_password); enable = streq(argv[0], "enable"); @@ -1824,7 +1820,7 @@ static int enable_machine(int argc, char *argv[], void *userdata) { return bus_log_parse_error(r); } - r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); if (r < 0) return r; diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index bb9182ad427..eec9c63d0b8 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -556,13 +556,9 @@ static int maybe_enable_disable(sd_bus *bus, const char *path, bool enable) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_strv_free_ char **names = NULL; - InstallChange *changes = NULL; const uint64_t flags = UNIT_FILE_PORTABLE | (arg_runtime ? UNIT_FILE_RUNTIME : 0); - size_t n_changes = 0; int r; - CLEANUP_ARRAY(changes, n_changes, install_changes_free); - if (!arg_enable) return 0; @@ -599,7 +595,7 @@ static int maybe_enable_disable(sd_bus *bus, const char *path, bool enable) { return bus_log_parse_error(r); } - (void) bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + (void) bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); return 0; } diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 6966cfd8389..3307691f281 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -2708,14 +2708,13 @@ int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char return 0; } -int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, InstallChange **changes, size_t *n_changes) { +int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet) { const char *type, *path, *source; + InstallChange *changes = NULL; + size_t n_changes = 0; int r; - /* changes is dereferenced when calling install_changes_dump() later, - * so we have to make sure this is not NULL. */ - assert(changes); - assert(n_changes); + CLEANUP_ARRAY(changes, n_changes, install_changes_free); r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(sss)"); if (r < 0) @@ -2733,7 +2732,7 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, In continue; } - r = install_changes_add(changes, n_changes, t, path, source); + r = install_changes_add(&changes, &n_changes, t, path, source); if (r < 0) return r; } @@ -2744,7 +2743,8 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, In if (r < 0) return bus_log_parse_error(r); - install_changes_dump(0, NULL, *changes, *n_changes, quiet); + install_changes_dump(0, NULL, changes, n_changes, quiet); + return 0; } diff --git a/src/shared/bus-unit-util.h b/src/shared/bus-unit-util.h index 789a142e1d8..97d84708b42 100644 --- a/src/shared/bus-unit-util.h +++ b/src/shared/bus-unit-util.h @@ -25,7 +25,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u); int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const char *assignment); int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char **l); -int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, InstallChange **changes, size_t *n_changes); +int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet); int unit_load_state(sd_bus *bus, const char *name, char **load_state); diff --git a/src/systemctl/systemctl-add-dependency.c b/src/systemctl/systemctl-add-dependency.c index b0bed577cca..aa3844f4d42 100644 --- a/src/systemctl/systemctl-add-dependency.c +++ b/src/systemctl/systemctl-add-dependency.c @@ -70,7 +70,7 @@ int verb_add_dependency(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to add dependency: %s", bus_error_message(&error, r)); - r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); if (r < 0) return r; diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c index 2fc5a0b051d..98bf30670df 100644 --- a/src/systemctl/systemctl-enable.c +++ b/src/systemctl/systemctl-enable.c @@ -235,7 +235,7 @@ int verb_enable(int argc, char *argv[], void *userdata) { return bus_log_parse_error(r); } - r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); if (r < 0) return r; diff --git a/src/systemctl/systemctl-preset-all.c b/src/systemctl/systemctl-preset-all.c index 70e302e1266..5d731729888 100644 --- a/src/systemctl/systemctl-preset-all.c +++ b/src/systemctl/systemctl-preset-all.c @@ -44,7 +44,7 @@ int verb_preset_all(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to preset all units: %s", bus_error_message(&error, r)); - r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); if (r < 0) return r; diff --git a/src/systemctl/systemctl-set-default.c b/src/systemctl/systemctl-set-default.c index 55f696565eb..3b161d7cbad 100644 --- a/src/systemctl/systemctl-set-default.c +++ b/src/systemctl/systemctl-set-default.c @@ -130,7 +130,7 @@ int verb_set_default(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to set default target: %s", bus_error_message(&error, r)); - r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); + r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet); if (r < 0) return r;