From owner-cvs-all Sat Aug 21 1:20:18 1999 Delivered-To: cvs-all@freebsd.org Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (Postfix) with ESMTP id A4BDC14E20; Sat, 21 Aug 1999 01:19:58 -0700 (PDT) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id SAA12283; Sat, 21 Aug 1999 18:18:44 +1000 Date: Sat, 21 Aug 1999 18:18:44 +1000 From: Bruce Evans Message-Id: <199908210818.SAA12283@godzilla.zeta.org.au> To: green@FreeBSD.org, phk@critter.freebsd.dk Subject: Re: cvs commit: src/sys/kern kern_physio.c Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk >>> Revision Changes Path >>> 1.37 +8 -2 src/sys/kern/kern_physio.c >> >>- bp->b_blkno = btodb(uio->uio_offset); >>+ blockno = uio->uio_offset >> DEV_BSHIFT; >>+ bp->b_blkno = blockno; >>+ if (bp->b_blkno != blockno) { >> ^- How can this comparison ever fail? > >They're different sizes. They're different types (long and quad_t), but have the same size on some machines (e.g., alphas). The check is written to make it difficult for compilers to optimise it away on these machines. It should be written something like: blockno = uio->uio_offset >> DEV_BSHIFT; if ((daddr_t)blockno != blockno) barf(); bp->b_blkno = blockno; or blockno = uio->uio_offset >> DEV_BSHIFT; if (blockno > DADDR_T_MAX) barf(); bp->b_blkno = blockno; btodb() probably shouldn't cast to daddr_t. This mainly prevents its use in code like the above. It is not a feature that it may prevent warnings about truncation when off_t's are assigned to daddr_t's. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message