From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSYRX-0008Oa-Oq for qemu-devel@nongnu.org; Thu, 29 Jan 2009 10:04:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSYRV-0008NT-QB for qemu-devel@nongnu.org; Thu, 29 Jan 2009 10:04:35 -0500 Received: from [199.232.76.173] (port=56970 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSYRV-0008NM-Ig for qemu-devel@nongnu.org; Thu, 29 Jan 2009 10:04:33 -0500 Received: from mx20.gnu.org ([199.232.41.8]:53980) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSYRV-0006kp-6B for qemu-devel@nongnu.org; Thu, 29 Jan 2009 10:04:33 -0500 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LSYRT-0000Ur-3e for qemu-devel@nongnu.org; Thu, 29 Jan 2009 10:04:31 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] support >2TB SCSI disks Date: Thu, 29 Jan 2009 15:04:25 +0000 References: <20090127224619.3ae16173@bree.surriel.com> <200901281230.29455.paul@codesourcery.com> <20090128.092842.-1889956563.imp@bsdimp.com> In-Reply-To: <20090128.092842.-1889956563.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200901291504.26517.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "M. Warner Losh" Cc: qemu-devel@nongnu.org > : > =A0 =A0 =A0case 0: > : > - =A0 =A0 =A0 =A0lba =3D buf[3] | (buf[2] << 8) | ((buf[1] & 0x1f) <<= 16); > : > + =A0 =A0 =A0 =A0lba =3D (uint64_t) buf[3] | ((uint64_t) buf[2] << 8)= | > : > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(((uint64_t) buf[1] & 0x1f) << 16); > : > : This is not required, though I guess it's harmless. > > Actually, I think it is required. ANSI-C promotion rules say that a > char or unsigned char is promoted to an int when used in an > expression. This causes the result to be a 32-bit number which is > sign-extended to a 64-bit number before being assigned to lba. Read the code again. You'll notice that the largest possible value is=20 0x001fffff, so it doesn't matter which way you extend from 32 to 64 bits. Paul