mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
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.
This commit is contained in:
parent
dc68fed25d
commit
c9d5c9c0e1
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user