Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2014 20:56:09 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271486 - head/sys/kern
Message-ID:  <201409122056.s8CKu90H056147@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409122056.s8CKu90H056147>