From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kix1I-0003Dx-Lg for qemu-devel@nongnu.org; Thu, 25 Sep 2008 16:01:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kix1F-0003Dl-92 for qemu-devel@nongnu.org; Thu, 25 Sep 2008 16:00:59 -0400 Received: from [199.232.76.173] (port=32960 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kix1F-0003Di-1y for qemu-devel@nongnu.org; Thu, 25 Sep 2008 16:00:57 -0400 Received: from mail-gx0-f19.google.com ([209.85.217.19]:49208) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kix1E-0001Cy-Kr for qemu-devel@nongnu.org; Thu, 25 Sep 2008 16:00:56 -0400 Received: by gxk12 with SMTP id 12so8015662gxk.10 for ; Thu, 25 Sep 2008 13:00:56 -0700 (PDT) Message-ID: <48DBEDBC.80400@codemonkey.ws> Date: Thu, 25 Sep 2008 14:59:56 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [5274] Add signed versions of save/load functions References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Blue Swirl 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