|
From: | Anthony Liguori |
Subject: | Re: [Qemu-devel] [5274] Add signed versions of save/load functions |
Date: | Thu, 25 Sep 2008 14:59:56 -0500 |
User-agent: | Thunderbird 2.0.0.16 (X11/20080723) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |