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

This commit is contained in:
Lennart Poettering
2021-04-20 10:23:30 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent fd2f6f7248
commit 4d686e6b0b
+4 -2
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);