From owner-cvs-all Sun Dec 19 2:30:36 1999 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 142B615223; Sun, 19 Dec 1999 02:30:30 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (beefcake.zeta.org.au [203.26.10.12]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id VAB32141; Sun, 19 Dec 1999 21:30:18 +1100 Date: Sun, 19 Dec 1999 21:30:01 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Andrew Gallatin Cc: Matt Dillon , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/nfs nfs_serv.c In-Reply-To: <14423.40355.215768.533614@grasshopper.cs.duke.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk On Wed, 15 Dec 1999, Andrew Gallatin wrote: > How about casting to a vm_offset_t? > Index: nfs_serv.c > =================================================================== > RCS file: /home/ncvs/src/sys/nfs/nfs_serv.c,v > retrieving revision 1.90 > diff -u -r1.90 nfs_serv.c > --- nfs_serv.c 1999/12/13 17:34:45 1.90 > +++ nfs_serv.c 1999/12/15 13:59:31 > @@ -871,7 +871,7 @@ > * Locate best candidate > */ > > - hi = ((int)vp / sizeof(struct vnode)) & (NUM_HEURISTIC - 1); > + hi = ((vm_offset_t)vp / sizeof(struct vnode)) & (NUM_HEURISTIC - 1); > nh = &nfsheur[hi]; > > while (try--) { For C9x conformance, you have to cast the pointer to void * first, then to intptr_t or uintptr_t. Many hash functions already do the latter. Most get it wrong by omitting the cast to void *. For bug for bug compatibility, you have to cast eventually to a signed int. If this is not done, then differences due to sign extension occur when size_t is smaller than int, and pessimizations occur when vm_offset_t is larger than size_t. For KNF conformance, lines must be no longer than 80 characters. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message