svn commit: r330355 - stable/11/sys/kern
Eitan Adler
eadler at FreeBSD.org
Sat Mar 3 21:05:29 UTC 2018
Author: eadler
Date: Sat Mar 3 21:05:28 2018
New Revision: 330355
URL: https://svnweb.freebsd.org/changeset/base/330355
Log:
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()
Modified:
stable/11/sys/kern/sys_capability.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/sys_capability.c
==============================================================================
--- stable/11/sys/kern/sys_capability.c Sat Mar 3 20:42:39 2018 (r330354)
+++ stable/11/sys/kern/sys_capability.c Sat Mar 3 21:05:28 2018 (r330355)
@@ -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);
}
More information about the svn-src-stable-11
mailing list