[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] support >2TB SCSI disks
From: |
M. Warner Losh |
Subject: |
Re: [Qemu-devel] [PATCH] support >2TB SCSI disks |
Date: |
Wed, 28 Jan 2009 09:28:42 -0700 (MST) |
In message: <address@hidden>
Paul Brook <address@hidden> writes:
: > case 0:
: > - lba = buf[3] | (buf[2] << 8) | ((buf[1] & 0x1f) << 16);
: > + lba = (uint64_t) buf[3] | ((uint64_t) buf[2] << 8) |
: > + (((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