summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-11-28 19:41:20 +0100
committerLennart Poettering <lennart@poettering.net>2016-12-01 00:25:51 +0100
commitc9d5c9c0e19eea79ca0f09fe58e5c0b76b8001e2 (patch)
tree90466e55295734e2853cf570eb96d5790d8facc4 /src/core
parentdc68fed25db7d7a84b4da0e7ed4e73152773a561 (diff)
core: make unit_free() accept NULL pointers
We generally try to make our destructors robust regarding NULL pointers, much in the same way as glibc's free(). Do this also for unit_free(). Follow-up for #4748.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/device.c2
-rw-r--r--src/core/mount.c2
-rw-r--r--src/core/swap.c2
-rw-r--r--src/core/unit.c3
4 files changed, 5 insertions, 4 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 8e2e3c7bed..074e93ffe2 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -359,7 +359,7 @@ static int device_setup_unit(Manager *m, struct udev_device *dev, const char *pa
fail:
log_unit_warning_errno(u, r, "Failed to set up device unit: %m");
- if (delete && u)
+ if (delete)
unit_free(u);
return r;
diff --git a/src/core/mount.c b/src/core/mount.c
index 1c2be28d55..0c4d061c27 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1509,7 +1509,7 @@ static int mount_setup_unit(
fail:
log_warning_errno(r, "Failed to set up mount unit: %m");
- if (delete && u)
+ if (delete)
unit_free(u);
return r;
diff --git a/src/core/swap.c b/src/core/swap.c
index bf404db8c3..e9468e105c 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -420,7 +420,7 @@ static int swap_setup_unit(
fail:
log_unit_warning_errno(u, r, "Failed to load swap unit: %m");
- if (delete && u)
+ if (delete)
unit_free(u);
return r;
diff --git a/src/core/unit.c b/src/core/unit.c
index cba6342eca..e485c01fc1 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -516,7 +516,8 @@ void unit_free(Unit *u) {
Iterator i;
char *t;
- assert(u);
+ if (!u)
+ return;
if (u->transient_file)
fclose(u->transient_file);