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@freqlabs.com>
Reviewed by:	oshogbo, ed
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7369
This commit is contained in:
Allan Jude 2016-08-31 17:52:11 +00:00
parent cc14fb4c2e
commit 61bd7ae0ec

View File

@ -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);
}