summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-07-01 18:59:28 +0200
committerMike Yuan <me@yhndnzj.com>2024-07-01 18:59:28 +0200
commit71c404f9cf8b953562a3840421d615e324c61be0 (patch)
treeeefb73338ed74dcbf73a014be085ce839da21314 /src/shared
parentMerge pull request #33475 from poettering/name-to-handle-at-fid (diff)
downloadsystemd-71c404f9cf8b953562a3840421d615e324c61be0.tar.xz
systemd-71c404f9cf8b953562a3840421d615e324c61be0.zip
shared/mount-util: return early if param is NULL
To make things more readable and consistent.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/mount-util.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/shared/mount-util.h b/src/shared/mount-util.h
index 20c63e137f..c260eef02a 100644
--- a/src/shared/mount-util.h
+++ b/src/shared/mount-util.h
@@ -83,19 +83,22 @@ int mount_flags_to_string(unsigned long flags, char **ret);
/* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */
static inline char* umount_and_rmdir_and_free(char *p) {
+ if (!p)
+ return NULL;
+
PROTECT_ERRNO;
- if (p) {
- (void) umount_recursive(p, 0);
- (void) rmdir(p);
- }
+ (void) umount_recursive(p, 0);
+ (void) rmdir(p);
return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free);
-static inline char *umount_and_free(char *p) {
+static inline char* umount_and_free(char *p) {
+ if (!p)
+ return NULL;
+
PROTECT_ERRNO;
- if (p)
- (void) umount_recursive(p, 0);
+ (void) umount_recursive(p, 0);
return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_free);