[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] support >2TB SCSI disks
From: |
Paul Brook |
Subject: |
Re: [Qemu-devel] [PATCH] support >2TB SCSI disks |
Date: |
Thu, 29 Jan 2009 15:04:25 +0000 |
User-agent: |
KMail/1.9.9 |
> : > 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.
Read the code again. You'll notice that the largest possible value is
0x001fffff, so it doesn't matter which way you extend from 32 to 64 bits.
Paul