From 0ed667f6e5e6cb02aa7c78b79c45fc9e205a9138 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 12 Sep 2014 20:56:09 +0000 Subject: [PATCH] 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(). --- sys/kern/kern_descrip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 9028c4e025c9..6d15c474ee0e 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -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); }