From: Christian Göttsche Date: Mon, 16 Dec 2024 16:40:02 +0000 (+0100) Subject: selinux: rework match_ipv6_addrmask() X-Git-Tag: v6.14-rc1~165^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e99b81f48cd565a5341c921e62fd09184d6bb72;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Paul Moore --- diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 1c4ac392df2a6..9bd14256a1544 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; } /**