[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [5274] Add signed versions of save/load functions
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [5274] Add signed versions of save/load functions |
Date: |
Thu, 25 Sep 2008 23:17:20 +0300 |
On 9/25/08, Anthony Liguori <address@hidden> 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.