From owner-svn-src-stable-11@freebsd.org Sat Mar 3 21:05:29 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F423F3C4C9; Sat, 3 Mar 2018 21:05:29 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F38F6767FE; Sat, 3 Mar 2018 21:05:28 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED4D33CAC; Sat, 3 Mar 2018 21:05:28 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w23L5SLW053019; Sat, 3 Mar 2018 21:05:28 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w23L5SfD053018; Sat, 3 Mar 2018 21:05:28 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803032105.w23L5SfD053018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 3 Mar 2018 21:05:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330355 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 330355 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 21:05:29 -0000 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); }