svn commit: r305137 - head/sys/kern
Allan Jude
allanjude at FreeBSD.org
Wed Aug 31 17:52:13 UTC 2016
Author: allanjude
Date: Wed Aug 31 17:52:11 2016
New Revision: 305137
URL: https://svnweb.freebsd.org/changeset/base/305137
Log:
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()
Submitted by: Ryan Moeller <ryan at freqlabs.com>
Reviewed by: oshogbo, ed
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D7369
Modified:
head/sys/kern/sys_capability.c
Modified: head/sys/kern/sys_capability.c
==============================================================================
--- head/sys/kern/sys_capability.c Wed Aug 31 17:36:43 2016 (r305136)
+++ head/sys/kern/sys_capability.c Wed Aug 31 17:52:11 2016 (r305137)
@@ -150,16 +150,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-head
mailing list