]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selinux: rework match_ipv6_addrmask()
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 16 Dec 2024 16:40:02 +0000 (17:40 +0100)
committerPaul Moore <paul@paul-moore.com>
Wed, 8 Jan 2025 04:14:38 +0000 (23:14 -0500)
Constify parameters, add size hints, and simplify control flow.

According to godbolt the same assembly is generated.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/services.c

index 1c4ac392df2a60a523a962c73603874d03c7a03a..9bd14256a1544da4f3f648a701bd7768654b69d9 100644 (file)
@@ -2597,17 +2597,15 @@ out:
        return rc;
 }
 
-static int match_ipv6_addrmask(u32 *input, u32 *addr, u32 *mask)
+static bool match_ipv6_addrmask(const u32 input[4], const u32 addr[4], const u32 mask[4])
 {
-       int i, fail = 0;
+       int i;
 
        for (i = 0; i < 4; i++)
-               if (addr[i] != (input[i] & mask[i])) {
-                       fail = 1;
-                       break;
-               }
+               if (addr[i] != (input[i] & mask[i]))
+                       return false;
 
-       return !fail;
+       return true;
 }
 
 /**