qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org, Blue Swirl <blauwirbel@gmail.com>
Subject: Re: [Qemu-devel] [5274] Add signed versions of save/load functions
Date: Thu, 25 Sep 2008 14:59:56 -0500	[thread overview]
Message-ID: <48DBEDBC.80400@codemonkey.ws> (raw)
In-Reply-To: <E1KgxRs-0002UK-Ch@cvs.savannah.gnu.org>

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.

Regards,

Anthony Liguori

  parent reply	other threads:[~2008-09-25 20:01 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 [this message]
2008-09-25 20:17   ` Blue Swirl
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=48DBEDBC.80400@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=blauwirbel@gmail.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).