Date: Mon, 22 Apr 2013 01:26:13 +0000 (UTC) From: Alan Cox <alc@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249745 - head/sys/vm Message-ID: <201304220126.r3M1QDf3030925@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: alc Date: Mon Apr 22 01:26:13 2013 New Revision: 249745 URL: http://svnweb.freebsd.org/changeset/base/249745 Log: Simplify vm_radix_{add,dec}lev(). Sponsored by: EMC / Isilon Storage Division Modified: head/sys/vm/vm_radix.c Modified: head/sys/vm/vm_radix.c ============================================================================== --- head/sys/vm/vm_radix.c Sun Apr 21 22:47:24 2013 (r249744) +++ head/sys/vm/vm_radix.c Mon Apr 22 01:26:13 2013 (r249745) @@ -265,16 +265,19 @@ vm_radix_keybarr(struct vm_radix_node *r static __inline int vm_radix_addlev(vm_pindex_t *idx, boolean_t *levels, uint16_t ilev) { - vm_pindex_t wrapidx; for (; levels[ilev] == FALSE || vm_radix_slot(*idx, ilev) == (VM_RADIX_COUNT - 1); ilev--) if (ilev == 0) return (1); - wrapidx = *idx; + + /* + * The following computation cannot overflow because *idx's slot at + * ilev is less than VM_RADIX_COUNT - 1. + */ *idx = vm_radix_trimkey(*idx, ilev); *idx += VM_RADIX_UNITLEVEL(ilev); - return (*idx < wrapidx); + return (0); } /* @@ -286,17 +289,19 @@ vm_radix_addlev(vm_pindex_t *idx, boolea static __inline int vm_radix_declev(vm_pindex_t *idx, boolean_t *levels, uint16_t ilev) { - vm_pindex_t wrapidx; for (; levels[ilev] == FALSE || vm_radix_slot(*idx, ilev) == 0; ilev--) if (ilev == 0) return (1); - wrapidx = *idx; + + /* + * The following computation cannot overflow because *idx's slot at + * ilev is greater than 0. + */ *idx = vm_radix_trimkey(*idx, ilev); - *idx |= VM_RADIX_UNITLEVEL(ilev) - 1; - *idx -= VM_RADIX_UNITLEVEL(ilev); - return (*idx > wrapidx); + *idx -= 1; + return (0); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304220126.r3M1QDf3030925>