"Michael S. Tsirkin" <m...@redhat.com> 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? [...]