From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSDJ3-0008PU-ND for qemu-devel@nongnu.org; Wed, 28 Jan 2009 11:30:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSDJ2-0008NJ-1I for qemu-devel@nongnu.org; Wed, 28 Jan 2009 11:30:25 -0500 Received: from [199.232.76.173] (port=37962 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSDJ1-0008NC-S7 for qemu-devel@nongnu.org; Wed, 28 Jan 2009 11:30:23 -0500 Received: from bsdimp.com ([199.45.160.85]:57811 helo=harmony.bsdimp.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSDJ1-0006oA-CH for qemu-devel@nongnu.org; Wed, 28 Jan 2009 11:30:23 -0500 Date: Wed, 28 Jan 2009 09:28:42 -0700 (MST) Message-Id: <20090128.092842.-1889956563.imp@bsdimp.com> Subject: Re: [Qemu-devel] [PATCH] support >2TB SCSI disks From: "M. Warner Losh" In-Reply-To: <200901281230.29455.paul@codesourcery.com> References: <20090127224619.3ae16173@bree.surriel.com> <200901281230.29455.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, paul@codesourcery.com In message: <200901281230.29455.paul@codesourcery.com> Paul Brook writes: : > =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. I've hit this "bug" in C before many times, and the patch specifically called it out as a problem. Warner