1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

mount-util: make umount_and_rmdir_and_freep() cleanup handler deal with NULL

This commit is contained in:
Lennart Poettering 2021-04-19 22:50:32 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent fd2f6f7248
commit 4d686e6b0b

View File

@ -93,8 +93,10 @@ int mode_to_inaccessible_node(const char *runtime_dir, mode_t mode, char **dest)
/* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */
static inline char* umount_and_rmdir_and_free(char *p) {
PROTECT_ERRNO;
(void) umount_recursive(p, 0);
(void) rmdir(p);
if (p) {
(void) umount_recursive(p, 0);
(void) rmdir(p);
}
return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free);