summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analyze/analyze.c3
-rw-r--r--src/basic/bitmap.c3
-rw-r--r--src/basic/lockfile-util.c3
-rw-r--r--src/basic/strv.c3
-rw-r--r--src/core/automount.c3
-rw-r--r--src/core/busname.c3
-rw-r--r--src/core/dbus-execute.c6
-rw-r--r--src/core/device.c3
-rw-r--r--src/core/execute.c42
-rw-r--r--src/core/load-fragment.c12
-rw-r--r--src/core/main.c3
-rw-r--r--src/core/manager.c9
-rw-r--r--src/core/mount.c3
-rw-r--r--src/core/scope.c3
-rw-r--r--src/core/service.c20
-rw-r--r--src/core/socket.c7
-rw-r--r--src/core/swap.c17
-rw-r--r--src/hostname/hostnamed.c9
-rw-r--r--src/import/export-tar.c6
-rw-r--r--src/import/import-raw.c3
-rw-r--r--src/import/import-tar.c3
-rw-r--r--src/import/pull-dkr.c6
-rw-r--r--src/journal-remote/journal-gatewayd.c3
-rw-r--r--src/journal-remote/journal-remote-write.c3
-rw-r--r--src/journal-remote/journal-upload-journal.c3
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c6
-rw-r--r--src/libsystemd/sd-bus/bus-message.c3
-rw-r--r--src/libsystemd/sd-bus/busctl-introspect.c3
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c6
-rw-r--r--src/libsystemd/sd-netlink/netlink-message.c6
-rw-r--r--src/libudev/libudev-list.c3
-rw-r--r--src/login/logind-dbus.c3
-rw-r--r--src/login/logind-inhibit.c3
-rw-r--r--src/login/logind-session.c3
-rw-r--r--src/login/logind-user.c3
-rw-r--r--src/machine/machine.c3
-rw-r--r--src/network/networkd-netdev-tuntap.c7
-rw-r--r--src/network/networkd-wait-online-link.c6
-rw-r--r--src/shared/bus-util.c7
-rw-r--r--src/shared/conf-parser.c3
-rw-r--r--src/udev/udev-rules.c9
41 files changed, 80 insertions, 173 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index ab7fb53269..e38a4340b6 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -582,8 +582,7 @@ static int analyze_plot(sd_bus *bus) {
if (u->activating < boot->userspace_time ||
u->activating > boot->finish_time) {
- free(u->name);
- u->name = NULL;
+ u->name = mfree(u->name);
continue;
}
diff --git a/src/basic/bitmap.c b/src/basic/bitmap.c
index 7ea3357031..2eabf3e1c1 100644
--- a/src/basic/bitmap.c
+++ b/src/basic/bitmap.c
@@ -145,8 +145,7 @@ bool bitmap_isclear(Bitmap *b) {
void bitmap_clear(Bitmap *b) {
assert(b);
- free(b->bitmaps);
- b->bitmaps = NULL;
+ b->bitmaps = mfree(b->bitmaps);
b->n_bitmaps = 0;
b->bitmaps_allocated = 0;
}
diff --git a/src/basic/lockfile-util.c b/src/basic/lockfile-util.c
index 05e16d1caa..f3ec6a3e52 100644
--- a/src/basic/lockfile-util.c
+++ b/src/basic/lockfile-util.c
@@ -145,8 +145,7 @@ void release_lock_file(LockFile *f) {
if ((f->operation & ~LOCK_NB) == LOCK_EX)
unlink_noerrno(f->path);
- free(f->path);
- f->path = NULL;
+ f->path = mfree(f->path);
}
f->fd = safe_close(f->fd);
diff --git a/src/basic/strv.c b/src/basic/strv.c
index eaf440a4b2..aa68d290f6 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -271,8 +271,7 @@ char **strv_split_newlines(const char *s) {
return l;
if (isempty(l[n-1])) {
- free(l[n-1]);
- l[n-1] = NULL;
+ l[n - 1] = mfree(l[n - 1]);
}
return l;
diff --git a/src/core/automount.c b/src/core/automount.c
index b8171ddad7..5bb61b95d3 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -127,8 +127,7 @@ static void automount_done(Unit *u) {
unmount_autofs(a);
- free(a->where);
- a->where = NULL;
+ a->where = mfree(a->where);
set_free(a->tokens);
a->tokens = NULL;
diff --git a/src/core/busname.c b/src/core/busname.c
index d3c1282239..4020e9dd3c 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -95,8 +95,7 @@ static void busname_done(Unit *u) {
assert(n);
- free(n->name);
- n->name = NULL;
+ n->name = mfree(n->name);
busname_free_policy(n);
busname_unwatch_control_pid(n);
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 3c98a0b186..ed55fcfca2 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -786,8 +786,7 @@ int bus_exec_context_set_transient_property(
if (mode != UNIT_CHECK) {
if (isempty(uu)) {
- free(c->user);
- c->user = NULL;
+ c->user = mfree(c->user);
} else {
char *t;
@@ -814,8 +813,7 @@ int bus_exec_context_set_transient_property(
if (mode != UNIT_CHECK) {
if (isempty(gg)) {
- free(c->group);
- c->group = NULL;
+ c->group = mfree(c->group);
} else {
char *t;
diff --git a/src/core/device.c b/src/core/device.c
index 3f574b1832..7fdfacfddf 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -60,8 +60,7 @@ static void device_unset_sysfs(Device *d) {
else
hashmap_remove(devices, d->sysfs);
- free(d->sysfs);
- d->sysfs = NULL;
+ d->sysfs = mfree(d->sysfs);
}
static int device_set_sysfs(Device *d, const char *sysfs) {
diff --git a/src/core/execute.c b/src/core/execute.c
index 28eeeaad18..de5c16bd76 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1994,32 +1994,20 @@ void exec_context_done(ExecContext *c) {
c->environment_files = NULL;
for (l = 0; l < ELEMENTSOF(c->rlimit); l++) {
- free(c->rlimit[l]);
- c->rlimit[l] = NULL;
+ c->rlimit[l] = mfree(c->rlimit[l]);
}
- free(c->working_directory);
- c->working_directory = NULL;
- free(c->root_directory);
- c->root_directory = NULL;
-
- free(c->tty_path);
- c->tty_path = NULL;
-
- free(c->syslog_identifier);
- c->syslog_identifier = NULL;
-
- free(c->user);
- c->user = NULL;
-
- free(c->group);
- c->group = NULL;
+ c->working_directory = mfree(c->working_directory);
+ c->root_directory = mfree(c->root_directory);
+ c->tty_path = mfree(c->tty_path);
+ c->syslog_identifier = mfree(c->syslog_identifier);
+ c->user = mfree(c->user);
+ c->group = mfree(c->group);
strv_free(c->supplementary_groups);
c->supplementary_groups = NULL;
- free(c->pam_name);
- c->pam_name = NULL;
+ c->pam_name = mfree(c->pam_name);
if (c->capabilities) {
cap_free(c->capabilities);
@@ -2038,14 +2026,9 @@ void exec_context_done(ExecContext *c) {
if (c->cpuset)
CPU_FREE(c->cpuset);
- free(c->utmp_id);
- c->utmp_id = NULL;
-
- free(c->selinux_context);
- c->selinux_context = NULL;
-
- free(c->apparmor_profile);
- c->apparmor_profile = NULL;
+ c->utmp_id = mfree(c->utmp_id);
+ c->selinux_context = mfree(c->selinux_context);
+ c->apparmor_profile = mfree(c->apparmor_profile);
set_free(c->syscall_filter);
c->syscall_filter = NULL;
@@ -2090,8 +2073,7 @@ int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_p
void exec_command_done(ExecCommand *c) {
assert(c);
- free(c->path);
- c->path = NULL;
+ c->path = mfree(c->path);
strv_free(c->argv);
c->argv = NULL;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 542bf8eb26..0299fe7603 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1215,8 +1215,7 @@ int config_parse_exec_selinux_context(
assert(data);
if (isempty(rvalue)) {
- free(c->selinux_context);
- c->selinux_context = NULL;
+ c->selinux_context = mfree(c->selinux_context);
c->selinux_context_ignore = false;
return 0;
}
@@ -1265,8 +1264,7 @@ int config_parse_exec_apparmor_profile(
assert(data);
if (isempty(rvalue)) {
- free(c->apparmor_profile);
- c->apparmor_profile = NULL;
+ c->apparmor_profile = mfree(c->apparmor_profile);
c->apparmor_profile_ignore = false;
return 0;
}
@@ -1315,8 +1313,7 @@ int config_parse_exec_smack_process_label(
assert(data);
if (isempty(rvalue)) {
- free(c->smack_process_label);
- c->smack_process_label = NULL;
+ c->smack_process_label = mfree(c->smack_process_label);
c->smack_process_label_ignore = false;
return 0;
}
@@ -3575,8 +3572,7 @@ int unit_load_fragment(Unit *u) {
/* Hmm, this didn't work? Then let's get rid
* of the fragment path stored for us, so that
* we don't point to an invalid location. */
- free(u->fragment_path);
- u->fragment_path = NULL;
+ u->fragment_path = mfree(u->fragment_path);
}
}
diff --git a/src/core/main.c b/src/core/main.c
index fe8f1924bd..091af6a9df 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1843,8 +1843,7 @@ finish:
m = manager_free(m);
for (j = 0; j < ELEMENTSOF(arg_default_rlimit); j++) {
- free(arg_default_rlimit[j]);
- arg_default_rlimit[j] = NULL;
+ arg_default_rlimit[j] = mfree(arg_default_rlimit[j]);
}
arg_default_unit = mfree(arg_default_unit);
diff --git a/src/core/manager.c b/src/core/manager.c
index 56f2c92feb..cd0513fd69 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -674,8 +674,7 @@ static int manager_setup_notify(Manager *m) {
static const int one = 1;
/* First free all secondary fields */
- free(m->notify_socket);
- m->notify_socket = NULL;
+ m->notify_socket = mfree(m->notify_socket);
m->notify_event_source = sd_event_source_unref(m->notify_event_source);
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
@@ -2794,8 +2793,7 @@ static void trim_generator_dir(Manager *m, char **generator) {
return;
if (rmdir(*generator) >= 0) {
- free(*generator);
- *generator = NULL;
+ *generator = mfree(*generator);
}
return;
@@ -2866,8 +2864,7 @@ static void remove_generator_dir(Manager *m, char **generator) {
strv_remove(m->lookup_paths.unit_path, *generator);
(void) rm_rf(*generator, REMOVE_ROOT);
- free(*generator);
- *generator = NULL;
+ *generator = mfree(*generator);
}
static void manager_undo_generators(Manager *m) {
diff --git a/src/core/mount.c b/src/core/mount.c
index 2b81d17b9c..83746ca412 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -203,8 +203,7 @@ static void mount_done(Unit *u) {
assert(m);
- free(m->where);
- m->where = NULL;
+ m->where = mfree(m->where);
mount_parameters_done(&m->parameters_proc_self_mountinfo);
mount_parameters_done(&m->parameters_fragment);
diff --git a/src/core/scope.c b/src/core/scope.c
index 35cf0621be..98395becfd 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -476,8 +476,7 @@ int scope_abandon(Scope *s) {
if (!IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED))
return -ESTALE;
- free(s->controller);
- s->controller = NULL;
+ s->controller = mfree(s->controller);
/* The client is no longer watching the remaining processes,
* so let's step in here, under the assumption that the
diff --git a/src/core/service.c b/src/core/service.c
index 292fe50de8..1cf1fcffdc 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -142,8 +142,7 @@ static void service_unwatch_pid_file(Service *s) {
log_unit_debug(UNIT(s), "Stopping watch for PID file %s", s->pid_file_pathspec->path);
path_spec_unwatch(s->pid_file_pathspec);
path_spec_done(s->pid_file_pathspec);
- free(s->pid_file_pathspec);
- s->pid_file_pathspec = NULL;
+ s->pid_file_pathspec = mfree(s->pid_file_pathspec);
}
static int service_set_main_pid(Service *s, pid_t pid) {
@@ -287,14 +286,9 @@ static void service_done(Unit *u) {
assert(s);
- free(s->pid_file);
- s->pid_file = NULL;
-
- free(s->status_text);
- s->status_text = NULL;
-
- free(s->reboot_arg);
- s->reboot_arg = NULL;
+ s->pid_file = mfree(s->pid_file);
+ s->status_text = mfree(s->status_text);
+ s->reboot_arg = mfree(s->reboot_arg);
s->exec_runtime = exec_runtime_unref(s->exec_runtime);
exec_command_free_array(s->exec_command, _SERVICE_EXEC_COMMAND_MAX);
@@ -313,8 +307,7 @@ static void service_done(Unit *u) {
if (s->bus_name) {
unit_unwatch_bus_name(u, s->bus_name);
- free(s->bus_name);
- s->bus_name = NULL;
+ s->bus_name = mfree(s->bus_name);
}
s->bus_endpoint_fd = safe_close(s->bus_endpoint_fd);
@@ -1939,8 +1932,7 @@ static int service_start(Unit *u) {
s->forbid_restart = false;
s->reset_cpu_usage = true;
- free(s->status_text);
- s->status_text = NULL;
+ s->status_text = mfree(s->status_text);
s->status_errno = 0;
s->notify_state = NOTIFY_UNKNOWN;
diff --git a/src/core/socket.c b/src/core/socket.c
index 1014fad626..7d3d5eb78a 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -135,11 +135,8 @@ static void socket_done(Unit *u) {
unit_ref_unset(&s->service);
- free(s->tcp_congestion);
- s->tcp_congestion = NULL;
-
- free(s->bind_to_device);
- s->bind_to_device = NULL;
+ s->tcp_congestion = mfree(s->tcp_congestion);
+ s->bind_to_device = mfree(s->bind_to_device);
free(s->smack);
free(s->smack_ip_in);
diff --git a/src/core/swap.c b/src/core/swap.c
index 2f462e339d..a26bc58cfc 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -59,8 +59,7 @@ static void swap_unset_proc_swaps(Swap *s) {
if (!s->from_proc_swaps)
return;
- free(s->parameters_proc_swaps.what);
- s->parameters_proc_swaps.what = NULL;
+ s->parameters_proc_swaps.what = mfree(s->parameters_proc_swaps.what);
s->from_proc_swaps = false;
}
@@ -87,8 +86,7 @@ static int swap_set_devnode(Swap *s, const char *devnode) {
else
hashmap_remove(swaps, s->devnode);
- free(s->devnode);
- s->devnode = NULL;
+ s->devnode = mfree(s->devnode);
}
if (devnode) {
@@ -141,14 +139,9 @@ static void swap_done(Unit *u) {
swap_unset_proc_swaps(s);
swap_set_devnode(s, NULL);
- free(s->what);
- s->what = NULL;
-
- free(s->parameters_fragment.what);
- s->parameters_fragment.what = NULL;
-
- free(s->parameters_fragment.options);
- s->parameters_fragment.options = NULL;
+ s->what = mfree(s->what);
+ s->parameters_fragment.what = mfree(s->parameters_fragment.what);
+ s->parameters_fragment.options = mfree(s->parameters_fragment.options);
s->exec_runtime = exec_runtime_unref(s->exec_runtime);
exec_command_done_array(s->exec_command, _SWAP_EXEC_COMMAND_MAX);
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index e90ae54156..e1ce2e6b31 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -64,8 +64,7 @@ static void context_reset(Context *c) {
assert(c);
for (p = 0; p < _PROP_MAX; p++) {
- free(c->data[p]);
- c->data[p] = NULL;
+ c->data[p] = mfree(c->data[p]);
}
}
@@ -498,8 +497,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (isempty(name)) {
- free(c->data[PROP_STATIC_HOSTNAME]);
- c->data[PROP_STATIC_HOSTNAME] = NULL;
+ c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]);
} else {
char *h;
@@ -570,8 +568,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (isempty(name)) {
- free(c->data[prop]);
- c->data[prop] = NULL;
+ c->data[prop] = mfree(c->data[prop]);
} else {
char *h;
diff --git a/src/import/export-tar.c b/src/import/export-tar.c
index 5adc748c50..43fa9d1b03 100644
--- a/src/import/export-tar.c
+++ b/src/import/export-tar.c
@@ -287,8 +287,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
if (r >= 0)
e->quota_referenced = q.referenced;
- free(e->temp_path);
- e->temp_path = NULL;
+ e->temp_path = mfree(e->temp_path);
r = tempfn_random(path, NULL, &e->temp_path);
if (r < 0)
@@ -298,8 +297,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
r = btrfs_subvol_snapshot_fd(sfd, e->temp_path, BTRFS_SNAPSHOT_READ_ONLY|BTRFS_SNAPSHOT_RECURSIVE);
if (r < 0) {
log_debug_errno(r, "Couldn't create snapshot %s of %s, not exporting atomically: %m", e->temp_path, path);
- free(e->temp_path);
- e->temp_path = NULL;
+ e->temp_path = mfree(e->temp_path);
}
}
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index a27e81bbd4..5f7d25d063 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -249,8 +249,7 @@ static int raw_import_finish(RawImport *i) {
if (r < 0)
return log_error_errno(r, "Failed to move image into place: %m");
- free(i->temp_path);
- i->temp_path = NULL;
+ i->temp_path = mfree(i->temp_path);
return 0;
}
diff --git a/src/import/import-tar.c b/src/import/import-tar.c
index 7ffe83cc33..d2bfb30238 100644
--- a/src/import/import-tar.c
+++ b/src/import/import-tar.c
@@ -205,8 +205,7 @@ static int tar_import_finish(TarImport *i) {
if (r < 0)
return log_error_errno(r, "Failed to move image into place: %m");
- free(i->temp_path);
- i->temp_path = NULL;
+ i->temp_path = mfree(i->temp_path);
return 0;
}
diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c
index 5ff49baa22..0dab184af1 100644
--- a/src/import/pull-dkr.c
+++ b/src/import/pull-dkr.c
@@ -1211,10 +1211,8 @@ static void dkr_pull_job_on_finished(PullJob *j) {
log_info("Completed writing to layer %s.", i->final_path);
i->layer_job = pull_job_unref(i->layer_job);
- free(i->temp_path);
- i->temp_path = NULL;
- free(i->final_path);
- i->final_path = NULL;
+ i->temp_path = mfree(i->temp_path);
+ i->final_path = mfree(i->final_path);
i->current_ancestry ++;
r = dkr_pull_pull_layer(i);
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index ebdd9edfc3..52078b1b37 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -338,8 +338,7 @@ static int request_parse_range(
m->cursor[strcspn(m->cursor, WHITESPACE)] = 0;
if (isempty(m->cursor)) {
- free(m->cursor);
- m->cursor = NULL;
+ m->cursor = mfree(m->cursor);
}
return 0;
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index 99820fa7b8..40f4ff8e58 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -30,8 +30,7 @@ int iovw_put(struct iovec_wrapper *iovw, void* data, size_t len) {
}
void iovw_free_contents(struct iovec_wrapper *iovw) {
- free(iovw->iovec);
- iovw->iovec = NULL;
+ iovw->iovec = mfree(iovw->iovec);
iovw->size_bytes = iovw->count = 0;
}
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index 5fd639a76a..3d2e52cacf 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -21,8 +21,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
switch(u->entry_state) {
case ENTRY_CURSOR: {
- free(u->current_cursor);
- u->current_cursor = NULL;
+ u->current_cursor = mfree(u->current_cursor);
r = sd_journal_get_cursor(u->journal, &u->current_cursor);
if (r < 0)
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index c3cc2b7212..99b9aa8084 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -107,8 +107,7 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
free(c->cgroup_root);
free(c->description);
- free(c->supplementary_gids);
- c->supplementary_gids = NULL;
+ c->supplementary_gids = mfree(c->supplementary_gids);
strv_free(c->well_known_names);
c->well_known_names = NULL;
@@ -1016,8 +1015,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
return r;
} else {
if (c->cmdline_size == 0) {
- free(c->cmdline);
- c->cmdline = NULL;
+ c->cmdline = mfree(c->cmdline);
}
c->mask |= SD_BUS_CREDS_CMDLINE;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 366a026426..72e2b9f785 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -113,8 +113,7 @@ static void message_reset_containers(sd_bus_message *m) {
free(m->containers[i].offsets);
}
- free(m->containers);
- m->containers = NULL;
+ m->containers = mfree(m->containers);
m->n_containers = m->containers_allocated = 0;
m->root_container.index = 0;
diff --git a/src/libsystemd/sd-bus/busctl-introspect.c b/src/libsystemd/sd-bus/busctl-introspect.c
index 03e83d08a1..abe482fc46 100644
--- a/src/libsystemd/sd-bus/busctl-introspect.c
+++ b/src/libsystemd/sd-bus/busctl-introspect.c
@@ -55,8 +55,7 @@ static void context_reset_member(Context *c) {
}
static void context_reset_interface(Context *c) {
- free(c->interface_name);
- c->interface_name = NULL;
+ c->interface_name = mfree(c->interface_name);
c->interface_flags = 0;
context_reset_member(c);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 4a9181613a..2ac4b9be8e 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -820,8 +820,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
b->machine = machine;
machine = NULL;
} else {
- free(b->machine);
- b->machine = NULL;
+ b->machine = mfree(b->machine);
}
if (pid) {
@@ -880,8 +879,7 @@ static int parse_container_kernel_address(sd_bus *b, const char **p, char **guid
b->machine = machine;
machine = NULL;
} else {
- free(b->machine);
- b->machine = NULL;
+ b->machine = mfree(b->machine);
}
if (pid) {
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
index aee2ced2d9..e2a10ae2b4 100644
--- a/src/libsystemd/sd-netlink/netlink-message.c
+++ b/src/libsystemd/sd-netlink/netlink-message.c
@@ -843,8 +843,7 @@ int sd_netlink_message_exit_container(sd_netlink_message *m) {
assert_return(m->sealed, -EINVAL);
assert_return(m->n_containers > 0, -EINVAL);
- free(m->containers[m->n_containers].attributes);
- m->containers[m->n_containers].attributes = NULL;
+ m->containers[m->n_containers].attributes = mfree(m->containers[m->n_containers].attributes);
m->containers[m->n_containers].type_system = NULL;
m->n_containers --;
@@ -894,8 +893,7 @@ int sd_netlink_message_rewind(sd_netlink_message *m) {
rtnl_message_seal(m);
for (i = 1; i <= m->n_containers; i++) {
- free(m->containers[i].attributes);
- m->containers[i].attributes = NULL;
+ m->containers[i].attributes = mfree(m->containers[i].attributes);
}
m->n_containers = 0;
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 044ee3a0cb..19e9130be0 100644
--- a/src/libudev/libudev-list.c
+++ b/src/libudev/libudev-list.c
@@ -246,8 +246,7 @@ void udev_list_cleanup(struct udev_list *list)
struct udev_list_entry *entry_loop;
struct udev_list_entry *entry_tmp;
- free(list->entries);
- list->entries = NULL;
+ list->entries = mfree(list->entries);
list->entries_cur = 0;
list->entries_max = 0;
udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(list))
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index b6fa50aa52..050d0252ad 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1987,8 +1987,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
m->scheduled_shutdown_timeout_source = sd_event_source_unref(m->scheduled_shutdown_timeout_source);
m->wall_message_timeout_source = sd_event_source_unref(m->wall_message_timeout_source);
m->nologin_timeout_source = sd_event_source_unref(m->nologin_timeout_source);
- free(m->scheduled_shutdown_type);
- m->scheduled_shutdown_type = NULL;
+ m->scheduled_shutdown_type = mfree(m->scheduled_shutdown_type);
m->scheduled_shutdown_timeout = 0;
if (m->unlink_nologin) {
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index cfae186edd..0c9c1e5e97 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -333,8 +333,7 @@ void inhibitor_remove_fifo(Inhibitor *i) {
if (i->fifo_path) {
unlink(i->fifo_path);
- free(i->fifo_path);
- i->fifo_path = NULL;
+ i->fifo_path = mfree(i->fifo_path);
}
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 92a6027a7e..d2c5a29801 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -913,8 +913,7 @@ static void session_remove_fifo(Session *s) {
if (s->fifo_path) {
unlink(s->fifo_path);
- free(s->fifo_path);
- s->fifo_path = NULL;
+ s->fifo_path = mfree(s->fifo_path);
}
}
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 5d8a7571cd..f2c89e3653 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -560,8 +560,7 @@ static int user_remove_runtime_path(User *u) {
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
- free(u->runtime_path);
- u->runtime_path = NULL;
+ u->runtime_path = mfree(u->runtime_path);
return r;
}
diff --git a/src/machine/machine.c b/src/machine/machine.c
index a056ec3b08..b52ecd015c 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -600,8 +600,7 @@ void machine_release_unit(Machine *m) {
return;
(void) hashmap_remove(m->manager->machine_units, m->unit);
- free(m->unit);
- m->unit = NULL;
+ m->unit = mfree(m->unit);
}
static const char* const machine_class_table[_MACHINE_CLASS_MAX] = {
diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c
index ba84e802fc..6a808b6205 100644
--- a/src/network/networkd-netdev-tuntap.c
+++ b/src/network/networkd-netdev-tuntap.c
@@ -143,11 +143,8 @@ static void tuntap_done(NetDev *netdev) {
assert(t);
- free(t->user_name);
- t->user_name = NULL;
-
- free(t->group_name);
- t->group_name = NULL;
+ t->user_name = mfree(t->user_name);
+ t->group_name = mfree(t->group_name);
}
static int tuntap_verify(NetDev *netdev, const char *filename) {
diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c
index 2d5123788c..cacb4c257e 100644
--- a/src/network/networkd-wait-online-link.c
+++ b/src/network/networkd-wait-online-link.c
@@ -120,13 +120,11 @@ int link_update_rtnl(Link *l, sd_netlink_message *m) {
int link_update_monitor(Link *l) {
assert(l);
- free(l->operational_state);
- l->operational_state = NULL;
+ l->operational_state = mfree(l->operational_state);
sd_network_link_get_operational_state(l->ifindex, &l->operational_state);
- free(l->state);
- l->state = NULL;
+ l->state = mfree(l->state);
sd_network_link_get_setup_state(l->ifindex, &l->state);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index d9cc19700e..36c44227c5 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1884,11 +1884,8 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet) {
log_debug_errno(q, "Got result %s/%m for job %s", strna(d->result), strna(d->name));
}
- free(d->name);
- d->name = NULL;
-
- free(d->result);
- d->result = NULL;
+ d->name = mfree(d->name);
+ d->result = mfree(d->result);
}
return r;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 36150d8744..23512f0d35 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -232,8 +232,7 @@ static int parse_line(const char* unit,
"Unknown section '%s'. Ignoring.", n);
free(n);
- free(*section);
- *section = NULL;
+ *section = mfree(*section);
*section_line = 0;
*section_ignored = true;
} else {
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 43255fb9d4..62e21e13a7 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1686,12 +1686,10 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
strbuf_complete(rules->strbuf);
/* cleanup uid/gid cache */
- free(rules->uids);
- rules->uids = NULL;
+ rules->uids = mfree(rules->uids);
rules->uids_cur = 0;
rules->uids_max = 0;
- free(rules->gids);
- rules->gids = NULL;
+ rules->gids = mfree(rules->gids);
rules->gids_cur = 0;
rules->gids_max = 0;
@@ -2064,8 +2062,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
char program[UTIL_PATH_SIZE];
char result[UTIL_LINE_SIZE];
- free(event->program_result);
- event->program_result = NULL;
+ event->program_result = mfree(event->program_result);
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), program, sizeof(program));
log_debug("PROGRAM '%s' %s:%u",
program,