From: Paul Brook <paul@codesourcery.com>
To: "M. Warner Losh" <imp@bsdimp.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] support >2TB SCSI disks
Date: Thu, 29 Jan 2009 15:04:25 +0000 [thread overview]
Message-ID: <200901291504.26517.paul@codesourcery.com> (raw)
In-Reply-To: <20090128.092842.-1889956563.imp@bsdimp.com>
> : > 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
prev parent reply other threads:[~2009-01-29 15:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-28 3:46 [Qemu-devel] [PATCH] support >2TB SCSI disks Rik van Riel
2009-01-28 12:30 ` Paul Brook
2009-01-28 14:13 ` Rik van Riel
2009-01-28 16:28 ` M. Warner Losh
2009-01-29 15:04 ` Paul Brook [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200901291504.26517.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=imp@bsdimp.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).