Received: from [140.186.70.92] (port=37250 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFkQO-0004XR-7a for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:23:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFkPx-00076Z-SU for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:23:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFkPx-00076G-H2 for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:23:05 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA99N4RD011924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Nov 2010 04:23:04 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] Re: [PATCH] add VMSTATE_BOOL References: <1288623114-14439-1-git-send-email-kraxel@redhat.com> <20101108174752.GC8498@redhat.com> Date: Tue, 09 Nov 2010 10:23:02 +0100 In-Reply-To: <20101108174752.GC8498@redhat.com> (Michael S. Tsirkin's message of "Mon, 8 Nov 2010 19:47:52 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Gerd Hoffmann , qemu-devel@nongnu.org "Michael S. Tsirkin" writes: > On Mon, Nov 01, 2010 at 03:51:54PM +0100, Gerd Hoffmann wrote: [...] >> diff --git a/savevm.c b/savevm.c >> index 10057f3..14268ea 100644 >> --- a/savevm.c >> +++ b/savevm.c >> @@ -675,6 +675,27 @@ uint64_t qemu_get_be64(QEMUFile *f) >> return v; >> } >> >> +/* bool */ >> + >> +static int get_bool(QEMUFile *f, void *pv, size_t size) >> +{ >> + bool *v = pv; >> + *v = qemu_get_byte(f); >> + return 0; > > We must really validate that the value is 0 or 1. > If it's not, we will get undefined behaviour. Indeed. >> +} >> + >> +static void put_bool(QEMUFile *f, void *pv, size_t size) >> +{ >> + bool *v = pv; >> + qemu_put_byte(f, *v); > > Is there a guarantee that bool is a single byte, BTW? Nope. Does it matter? [...]