summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 5075e4e176..23fc946fbf 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1183,7 +1183,7 @@ static int list_timers(sd_bus *bus, char **args) {
for (u = unit_infos; u < unit_infos + n; u++) {
_cleanup_strv_free_ char **triggered = NULL;
- dual_timestamp next = {};
+ dual_timestamp next = DUAL_TIMESTAMP_NULL;
usec_t m, last = 0;
if (!endswith(u->id, ".timer"))
@@ -1678,17 +1678,23 @@ static const struct bus_properties_map machine_info_property_map[] = {
{}
};
+static void machine_info_clear(struct machine_info *info) {
+ if (info) {
+ free(info->name);
+ free(info->state);
+ free(info->control_group);
+ zero(*info);
+ }
+}
+
static void free_machines_list(struct machine_info *machine_infos, int n) {
int i;
if (!machine_infos)
return;
- for (i = 0; i < n; i++) {
- free(machine_infos[i].name);
- free(machine_infos[i].state);
- free(machine_infos[i].control_group);
- }
+ for (i = 0; i < n; i++)
+ machine_info_clear(&machine_infos[i]);
free(machine_infos);
}
@@ -4402,7 +4408,7 @@ static int show_all(
static int show_system_status(sd_bus *bus) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], since2[FORMAT_TIMESTAMP_MAX];
_cleanup_free_ char *hn = NULL;
- struct machine_info mi = {};
+ _cleanup_(machine_info_clear) struct machine_info mi = {};
const char *on, *off;
int r;
@@ -4449,9 +4455,6 @@ static int show_system_status(sd_bus *bus) {
show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false, get_output_flags());
}
- free(mi.state);
- free(mi.control_group);
-
return 0;
}
@@ -5684,7 +5687,7 @@ static int create_edit_temp_file(const char *new_path, const char *original_path
assert(original_path);
assert(ret_tmp_fn);
- r = tempfn_random(new_path, &t);
+ r = tempfn_random(new_path, NULL, &t);
if (r < 0)
return log_error_errno(r, "Failed to determine temporary filename for \"%s\": %m", new_path);