]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
simplify bitwise checking (#30722)
authorAtariDreams <83477269+AtariDreams@users.noreply.github.com>
Tue, 9 Jan 2024 01:18:10 +0000 (20:18 -0500)
committerGitHub <noreply@github.com>
Tue, 9 Jan 2024 01:18:10 +0000 (10:18 +0900)
Some of these checks before bitwise operations are redundant and compilers
do not always recognize them, so let's simplify the code to make the intentions
clearer.

src/core/namespace.c
src/shared/mount-util.c

index df6d0b4485c76ea52402a8bce7d6f6fa8a5efcf0..1bfd6b6ca0eb745bf0a503c7f27f34ccccbca26e 100644 (file)
@@ -626,8 +626,7 @@ static int append_tmpfs_mounts(MountList *ml, const TemporaryFileSystem *tmpfs,
                         return log_debug_errno(r, "Failed to parse mount option '%s': %m", str);
 
                 ro = flags & MS_RDONLY;
-                if (ro)
-                        flags ^= MS_RDONLY;
+                flags &= ~MS_RDONLY;
 
                 MountEntry *me = mount_list_extend(ml);
                 if (!me)
index ba3a9e995d13102c31673bd15033861881432f60..3305b6360e7a427c7468fbb846113172fda4741c 100644 (file)
@@ -821,8 +821,8 @@ int mount_option_mangle(
 
                         if (!(ent->mask & MNT_INVERT))
                                 mount_flags |= ent->id;
-                        else if (mount_flags & ent->id)
-                                mount_flags ^= ent->id;
+                        else
+                                mount_flags &= ~ent->id;
 
                         break;
                 }