qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [PATCH] add VMSTATE_BOOL


From: Markus Armbruster
Subject: Re: [Qemu-devel] Re: [PATCH] add VMSTATE_BOOL
Date: Tue, 09 Nov 2010 10:23:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

"Michael S. Tsirkin" <address@hidden> 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?

[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]