diff options
author | eadler <eadler@FreeBSD.org> | 2018-03-03 21:05:28 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2018-03-03 21:05:28 +0000 |
commit | 7dc6d4a39534a3ec53967838b4e5a3e360204e3b (patch) | |
tree | ed649becfd75041bd339f1c1186c6a9a7f6710f4 /sys/kern | |
parent | 4c0635ed2aca6621c0aacd13508ad23b45a5cb7c (diff) | |
download | FreeBSD-src-7dc6d4a39534a3ec53967838b4e5a3e360204e3b.zip FreeBSD-src-7dc6d4a39534a3ec53967838b4e5a3e360204e3b.tar.gz |
MFC r305137:
Eliminate unnecessary loop in _cap_check()
Calling cap_rights_contains() several times with the same inputs is not
going to produce a different output. The variable being iterated, i, is
never used inside the for loop.
The loop is actually done in cap_rights_contains()
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_capability.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/kern/sys_capability.c b/sys/kern/sys_capability.c index 584d7ee..65fc9ab 100644 --- a/sys/kern/sys_capability.c +++ b/sys/kern/sys_capability.c @@ -154,16 +154,13 @@ static inline int _cap_check(const cap_rights_t *havep, const cap_rights_t *needp, enum ktr_cap_fail_type type) { - int i; - for (i = 0; i < nitems(havep->cr_rights); i++) { - if (!cap_rights_contains(havep, needp)) { + if (!cap_rights_contains(havep, needp)) { #ifdef KTRACE - if (KTRPOINT(curthread, KTR_CAPFAIL)) - ktrcapfail(type, needp, havep); + if (KTRPOINT(curthread, KTR_CAPFAIL)) + ktrcapfail(type, needp, havep); #endif - return (ENOTCAPABLE); - } + return (ENOTCAPABLE); } return (0); } |