diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2024-12-16 17:40:02 +0100 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2025-01-07 23:14:38 -0500 |
commit | 5e99b81f48cd565a5341c921e62fd09184d6bb72 (patch) | |
tree | 0c3f0418be1ffdeed20e6ffc4932500c842dd7c3 | |
parent | 90903085101107b06158d2407bb2a6045af6dead (diff) |
selinux: rework match_ipv6_addrmask()
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>
-rw-r--r-- | security/selinux/ss/services.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 1c4ac392df2a..9bd14256a154 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -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; } /** |