From: "Blue Swirl" <blauwirbel@gmail.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [5274] Add signed versions of save/load functions
Date: Thu, 25 Sep 2008 23:17:20 +0300 [thread overview]
Message-ID: <f43fc5580809251317t635abfd4pa616121c2a2ade80@mail.gmail.com> (raw)
In-Reply-To: <48DBEDBC.80400@codemonkey.ws>
On 9/25/08, Anthony Liguori <anthony@codemonkey.ws> wrote:
> Blue Swirl wrote:
>
> > -int qemu_get_byte(QEMUFile *f)
> > +int8_t qemu_get_byte(QEMUFile *f)
> > {
> > if (f->buf_index >= f->buf_size) {
> > qemu_fill_buffer(f);
> > @@ -6329,13 +6329,13 @@
> > return pos;
> > }
> >
> >
>
> So this is the problem. While qemu_get_byte() returns an int, it returns
> f->buf[pos] and buf is a uint8_t *. This means that it will always return a
> positive number whereas the new qemu_get_byte() may return a negative
> number.
>
> When dealing with something like qemu_get_be32(), where you're shifting
> qemu_get_byte(), the int8_t is going to get promoted to an int and when the
> int8_t is negative, the result is that the combination is an OR of
> 0xFFFFFFFX instead of 0x000000FX.
>
> Which leads me to wonder, how much did you test this changeset? Because I
> don't think any save/restore could possibly have worked. Perhaps we should
> revert the whole patchset until it's a bit more flushed out? I'm concerned
> that integer promotion isn't taken into account in a number of places.
Right. I think the patch should be split into three operations: signed
version addition, int to size_t change and this dangerous type size
change. Only the first one is obviously correct, which I thought all
of these changes were.
Thanks for debugging, I'll revert this patch and make new patches for review.
next prev parent reply other threads:[~2008-09-25 20:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-20 8:04 [Qemu-devel] [5274] Add signed versions of save/load functions Blue Swirl
2008-09-25 18:23 ` Anthony Liguori
2008-09-25 18:47 ` Blue Swirl
2008-09-25 19:59 ` Anthony Liguori
2008-09-25 20:17 ` Blue Swirl [this message]
2008-09-25 20:20 ` Anthony Liguori
2008-09-25 21:14 ` Blue Swirl
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=f43fc5580809251317t635abfd4pa616121c2a2ade80@mail.gmail.com \
--to=blauwirbel@gmail.com \
--cc=anthony@codemonkey.ws \
--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).