From owner-svn-src-head@FreeBSD.ORG Fri Sep 12 20:56:10 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 14A2ADF; Fri, 12 Sep 2014 20:56:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 009D2867; Fri, 12 Sep 2014 20:56:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8CKu9UR056148; Fri, 12 Sep 2014 20:56:09 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8CKu90H056147; Fri, 12 Sep 2014 20:56:09 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201409122056.s8CKu90H056147@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 12 Sep 2014 20:56:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271486 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2014 20:56:10 -0000 Author: jhb Date: Fri Sep 12 20:56:09 2014 New Revision: 271486 URL: http://svnweb.freebsd.org/changeset/base/271486 Log: Simplify vntype_to_kinfo() by returning when the desired value is found instead of breaking out of the loop and then immediately checking the loop index so that if it was broken out of the proper value can be returned. While here, use nitems(). Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Sep 12 20:55:17 2014 (r271485) +++ head/sys/kern/kern_descrip.c Fri Sep 12 20:56:09 2014 (r271486) @@ -3531,17 +3531,14 @@ vntype_to_kinfo(int vtype) { VREG, KF_VTYPE_VREG }, { VSOCK, KF_VTYPE_VSOCK } }; -#define NVTYPES (sizeof(vtypes_table) / sizeof(*vtypes_table)) unsigned int i; /* * Perform vtype translation. */ - for (i = 0; i < NVTYPES; i++) + for (i = 0; i < nitems(vtypes_table); i++) if (vtypes_table[i].vtype == vtype) - break; - if (i < NVTYPES) - return (vtypes_table[i].kf_vtype); + return (vtypes_table[i].kf_vtype); return (KF_VTYPE_UNKNOWN); }