]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/mount-util: return early if param is NULL
authorMike Yuan <me@yhndnzj.com>
Mon, 1 Jul 2024 16:59:28 +0000 (18:59 +0200)
committerMike Yuan <me@yhndnzj.com>
Mon, 1 Jul 2024 16:59:28 +0000 (18:59 +0200)
To make things more readable and consistent.

src/shared/mount-util.h

index 20c63e137fe2623ff7abaf29b1a7a0097f07debe..c260eef02af30a722c68e4b980ebf43b1eba6e46 100644 (file)
@@ -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);