Date: Sat, 21 Aug 1999 18:18:44 +1000 From: Bruce Evans <bde@zeta.org.au> To: green@FreeBSD.org, phk@critter.freebsd.dk Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_physio.c Message-ID: <199908210818.SAA12283@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908210818.SAA12283>
