Skip to content

Commit 5e99b81

Browse files
cgzonespcmoore
authored andcommitted
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>
1 parent 9090308 commit 5e99b81

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

security/selinux/ss/services.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,17 +2597,15 @@ int security_netif_sid(char *name, u32 *if_sid)
25972597
return rc;
25982598
}
25992599

2600-
static int match_ipv6_addrmask(u32 *input, u32 *addr, u32 *mask)
2600+
static bool match_ipv6_addrmask(const u32 input[4], const u32 addr[4], const u32 mask[4])
26012601
{
2602-
int i, fail = 0;
2602+
int i;
26032603

26042604
for (i = 0; i < 4; i++)
2605-
if (addr[i] != (input[i] & mask[i])) {
2606-
fail = 1;
2607-
break;
2608-
}
2605+
if (addr[i] != (input[i] & mask[i]))
2606+
return false;
26092607

2610-
return !fail;
2608+
return true;
26112609
}
26122610

26132611
/**

0 commit comments

Comments
 (0)