Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Dec 1999 21:30:01 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Andrew Gallatin <gallatin@cs.duke.edu>
Cc:        Matt Dillon <dillon@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/nfs nfs_serv.c
Message-ID:  <Pine.BSF.4.10.9912192119560.6992-100000@alphplex.bde.org>
In-Reply-To: <14423.40355.215768.533614@grasshopper.cs.duke.edu>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9912192119560.6992-100000>