qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: don't use uninitialized variables
@ 2013-07-19  2:36 Pawit Pornkitprasan
  2013-07-19 10:57 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Pawit Pornkitprasan @ 2013-07-19  2:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pawit Pornkitprasan, Ryousei Takano, Juan Quintela

The qmp_migrate method uses the 'blk' and 'inc' parameter without
checking if they're valid or not (they may be uninitialized if
command is received via QMP)

Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
---
 migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration.c b/migration.c
index 9f5a423..f3d1ff7 100644
--- a/migration.c
+++ b/migration.c
@@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = blk;
-    params.shared = inc;
+    params.blk = has_blk && blk;
+    params.shared = has_inc && inc;
 
     if (s->state == MIG_STATE_ACTIVE) {
         error_set(errp, QERR_MIGRATION_ACTIVE);
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19  2:36 [Qemu-devel] [PATCH] migration: don't use uninitialized variables Pawit Pornkitprasan
@ 2013-07-19 10:57 ` Eric Blake
  2013-07-19 11:04   ` Pawit Pornkitprasan
  2013-07-29 21:05   ` Luiz Capitulino
  2013-07-22  7:32 ` Orit Wasserman
  2013-07-29 20:52 ` Luiz Capitulino
  2 siblings, 2 replies; 13+ messages in thread
From: Eric Blake @ 2013-07-19 10:57 UTC (permalink / raw)
  To: Pawit Pornkitprasan; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
> ---
>  migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

However, wouldn't it be nice if we improved the qapi generator to
guarantee a sane default value for optional parameters, even when
has_value is false?

> 
> diff --git a/migration.c b/migration.c
> index 9f5a423..f3d1ff7 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;
>  
>      if (s->state == MIG_STATE_ACTIVE) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19 10:57 ` Eric Blake
@ 2013-07-19 11:04   ` Pawit Pornkitprasan
  2013-07-19 11:13     ` Eric Blake
  2013-07-29 21:05   ` Luiz Capitulino
  1 sibling, 1 reply; 13+ messages in thread
From: Pawit Pornkitprasan @ 2013-07-19 11:04 UTC (permalink / raw)
  To: Eric Blake; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

On Fri, Jul 19, 2013 at 7:57 PM, Eric Blake <eblake@redhat.com> wrote:
>
> However, wouldn't it be nice if we improved the qapi generator to
> guarantee a sane default value for optional parameters, even when
> has_value is false?
>

I'm not a qemu expert or anything, but wouldn't that destroy the point
of has_value in the first place?

--
Pawit

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19 11:04   ` Pawit Pornkitprasan
@ 2013-07-19 11:13     ` Eric Blake
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Blake @ 2013-07-19 11:13 UTC (permalink / raw)
  To: Pawit Pornkitprasan; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]

On 07/19/2013 05:04 AM, Pawit Pornkitprasan wrote:
> On Fri, Jul 19, 2013 at 7:57 PM, Eric Blake <eblake@redhat.com> wrote:
>>
>> However, wouldn't it be nice if we improved the qapi generator to
>> guarantee a sane default value for optional parameters, even when
>> has_value is false?
>>
> 
> I'm not a qemu expert or anything, but wouldn't that destroy the point
> of has_value in the first place?

There are two uses for has_value.  One: on output, the user knows
whether the variable has been set to anything sane.  Two: on input, the
receiver knows if the caller passed an optional value.  For output,
has_value is always needed.  But for input, we could probably simplify a
LOT of code if 'value' already had a sane default of 0, without having
to first check 'has_value', instead of the current state where 'value'
must be treated as uninitialized if 'has_value' is false.  Improving the
qapi generator to guarantee 0 value of optional parameters that were not
specified in JSON should not block your patch (it would be a series by
itself), it's just a question of whether it is worth making the change
and the resulting simplifications we can make to code that can assume
sane default values.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19  2:36 [Qemu-devel] [PATCH] migration: don't use uninitialized variables Pawit Pornkitprasan
  2013-07-19 10:57 ` Eric Blake
@ 2013-07-22  7:32 ` Orit Wasserman
  2013-07-29 20:52 ` Luiz Capitulino
  2 siblings, 0 replies; 13+ messages in thread
From: Orit Wasserman @ 2013-07-22  7:32 UTC (permalink / raw)
  To: Pawit Pornkitprasan; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

On 07/19/2013 05:36 AM, Pawit Pornkitprasan wrote:
> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
> ---
>  migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 9f5a423..f3d1ff7 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;
>  
>      if (s->state == MIG_STATE_ACTIVE) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);
> 

Reviewed-by: Orit Wasserman <owasserm@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19  2:36 [Qemu-devel] [PATCH] migration: don't use uninitialized variables Pawit Pornkitprasan
  2013-07-19 10:57 ` Eric Blake
  2013-07-22  7:32 ` Orit Wasserman
@ 2013-07-29 20:52 ` Luiz Capitulino
  2013-07-29 23:29   ` Pawit Pornkitprasan
  2 siblings, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2013-07-29 20:52 UTC (permalink / raw)
  To: Pawit Pornkitprasan; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

On Fri, 19 Jul 2013 11:36:41 +0900
Pawit Pornkitprasan <p.pawit@gmail.com> wrote:

> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
> ---
>  migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 9f5a423..f3d1ff7 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;

This doesn't apply anymore, can you rebase and resend?

By grepping around I can see that there are several instances of
this bug in other commands. I'm surprised we never got a single
bug report about this... Would you mind to fix all the instances?

>  
>      if (s->state == MIG_STATE_ACTIVE) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-19 10:57 ` Eric Blake
  2013-07-19 11:04   ` Pawit Pornkitprasan
@ 2013-07-29 21:05   ` Luiz Capitulino
  2013-07-30  0:15     ` Markus Armbruster
  1 sibling, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2013-07-29 21:05 UTC (permalink / raw)
  To: Eric Blake; +Cc: Pawit Pornkitprasan, qemu-devel, Ryousei Takano, Juan Quintela

On Fri, 19 Jul 2013 04:57:51 -0600
Eric Blake <eblake@redhat.com> wrote:

> On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
> > The qmp_migrate method uses the 'blk' and 'inc' parameter without
> > checking if they're valid or not (they may be uninitialized if
> > command is received via QMP)
> > 
> > Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
> > ---
> >  migration.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> However, wouldn't it be nice if we improved the qapi generator to
> guarantee a sane default value for optional parameters, even when
> has_value is false?

We could do that for bool and pointers, but this wouldn't help
integers and enums. Also, even if we had default values, I guess
I'd enforce a common idiom for handling optionals as this is also
a good practice for preventing bugs.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-29 20:52 ` Luiz Capitulino
@ 2013-07-29 23:29   ` Pawit Pornkitprasan
  0 siblings, 0 replies; 13+ messages in thread
From: Pawit Pornkitprasan @ 2013-07-29 23:29 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Ryousei Takano, qemu-devel, Juan Quintela

On Tue, Jul 30, 2013 at 5:52 AM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
>
> This doesn't apply anymore, can you rebase and resend?
>

Sure.

> By grepping around I can see that there are several instances of
> this bug in other commands. I'm surprised we never got a single
> bug report about this... Would you mind to fix all the instances?
>

It's a bug I've found during my internship. As my internship is ending,
I won't be able to fix and test the other instances. Sorry about that.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-29 21:05   ` Luiz Capitulino
@ 2013-07-30  0:15     ` Markus Armbruster
  2013-07-30  1:29       ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Armbruster @ 2013-07-30  0:15 UTC (permalink / raw)
  To: Luiz Capitulino
  Cc: Pawit Pornkitprasan, qemu-devel, Ryousei Takano, Juan Quintela

Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Fri, 19 Jul 2013 04:57:51 -0600
> Eric Blake <eblake@redhat.com> wrote:
>
>> On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
>> > The qmp_migrate method uses the 'blk' and 'inc' parameter without
>> > checking if they're valid or not (they may be uninitialized if
>> > command is received via QMP)
>> > 
>> > Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
>> > ---
>> >  migration.c | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> 
>> However, wouldn't it be nice if we improved the qapi generator to
>> guarantee a sane default value for optional parameters, even when
>> has_value is false?
>
> We could do that for bool and pointers, but this wouldn't help
> integers and enums. Also, even if we had default values, I guess
> I'd enforce a common idiom for handling optionals as this is also
> a good practice for preventing bugs.

I disagree on pointers.

"have_ptr && ptr->..." is a stupid idiom.  The common idiom for safe
dereference is "ptr && ptr->...".

"bool have_ptr, FOO *ptr" in a parameter list is unidiomatic C.
Idiomatic is just "FOO *ptr".

Conciseness is a virtue.

For non-pointers, there's no special "don't have one" value, so we'd
have to declare a default value in the schema to get rid of the
have_FOO.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-30  0:15     ` Markus Armbruster
@ 2013-07-30  1:29       ` Anthony Liguori
  2013-07-30  6:39         ` Markus Armbruster
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2013-07-30  1:29 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Juan Quintela, Pawit Pornkitprasan, qemu-devel, Ryousei Takano,
	Luiz Capitulino

On Mon, Jul 29, 2013 at 7:15 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
>> On Fri, 19 Jul 2013 04:57:51 -0600
>> Eric Blake <eblake@redhat.com> wrote:
>>
>>> On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
>>> > The qmp_migrate method uses the 'blk' and 'inc' parameter without
>>> > checking if they're valid or not (they may be uninitialized if
>>> > command is received via QMP)
>>> >
>>> > Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
>>> > ---
>>> >  migration.c | 4 ++--
>>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>>
>>> However, wouldn't it be nice if we improved the qapi generator to
>>> guarantee a sane default value for optional parameters, even when
>>> has_value is false?
>>
>> We could do that for bool and pointers, but this wouldn't help
>> integers and enums. Also, even if we had default values, I guess
>> I'd enforce a common idiom for handling optionals as this is also
>> a good practice for preventing bugs.
>
> I disagree on pointers.
>
> "have_ptr && ptr->..." is a stupid idiom.  The common idiom for safe
> dereference is "ptr && ptr->...".
>
> "bool have_ptr, FOO *ptr" in a parameter list is unidiomatic C.
> Idiomatic is just "FOO *ptr".
>
> Conciseness is a virtue.
>
> For non-pointers, there's no special "don't have one" value, so we'd
> have to declare a default value in the schema to get rid of the
> have_FOO.

The problem is the protocol.  There are cases where the absence of a
value is different than having a default value for the parameter.

This was part of the discussion way back when this all was first
introduced.  Since everything was open coded and we had to preserve
the semantics, that was the only choice we had.

Regards.

Anthony Liguori

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-30  1:29       ` Anthony Liguori
@ 2013-07-30  6:39         ` Markus Armbruster
  2013-07-30 13:26           ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Armbruster @ 2013-07-30  6:39 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Juan Quintela, Pawit Pornkitprasan, qemu-devel, Ryousei Takano,
	Luiz Capitulino

Anthony Liguori <anthony@codemonkey.ws> writes:

> On Mon, Jul 29, 2013 at 7:15 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Luiz Capitulino <lcapitulino@redhat.com> writes:
>>
>>> On Fri, 19 Jul 2013 04:57:51 -0600
>>> Eric Blake <eblake@redhat.com> wrote:
>>>
>>>> On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
>>>> > The qmp_migrate method uses the 'blk' and 'inc' parameter without
>>>> > checking if they're valid or not (they may be uninitialized if
>>>> > command is received via QMP)
>>>> >
>>>> > Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
>>>> > ---
>>>> >  migration.c | 4 ++--
>>>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>>>
>>>> However, wouldn't it be nice if we improved the qapi generator to
>>>> guarantee a sane default value for optional parameters, even when
>>>> has_value is false?
>>>
>>> We could do that for bool and pointers, but this wouldn't help
>>> integers and enums. Also, even if we had default values, I guess
>>> I'd enforce a common idiom for handling optionals as this is also
>>> a good practice for preventing bugs.
>>
>> I disagree on pointers.
>>
>> "have_ptr && ptr->..." is a stupid idiom.  The common idiom for safe
>> dereference is "ptr && ptr->...".
>>
>> "bool have_ptr, FOO *ptr" in a parameter list is unidiomatic C.
>> Idiomatic is just "FOO *ptr".
>>
>> Conciseness is a virtue.
>>
>> For non-pointers, there's no special "don't have one" value, so we'd
>> have to declare a default value in the schema to get rid of the
>> have_FOO.
>
> The problem is the protocol.  There are cases where the absence of a
> value is different than having a default value for the parameter.
>
> This was part of the discussion way back when this all was first
> introduced.  Since everything was open coded and we had to preserve
> the semantics, that was the only choice we had.

Yes, there is a difference between an optional parameter with a default
value and one without.

If you got a value QMP clients cannot send, the difference can be
eliminated: just pass this value to stand for "nothing".  This is the
case for pointers: just pass NULL.  Like everybody else does when
passing "nothing".

When "nothing" is to be interpreted just like a context-independent
default value, then the difference doesn't matter.  The client doesn't
care, and the function handling the message becomes simpler.

Only when "nothing" can mean different things do you really need both
have_FOO and FOO parameters.

I can't see why we couldn't introduce default values into the schema if
we wanted, and use them to simplify generated code.

For pointers, we don't even need schema extensions to simplify away the
silly have_FOOs.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-30  6:39         ` Markus Armbruster
@ 2013-07-30 13:26           ` Anthony Liguori
  2013-07-30 15:22             ` Markus Armbruster
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2013-07-30 13:26 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Juan Quintela, Pawit Pornkitprasan, qemu-devel, Ryousei Takano,
	Luiz Capitulino

On Tue, Jul 30, 2013 at 1:39 AM, Markus Armbruster <armbru@redhat.com> wrote:
> Anthony Liguori <anthony@codemonkey.ws> writes:
>
>> This was part of the discussion way back when this all was first
>> introduced.  Since everything was open coded and we had to preserve
>> the semantics, that was the only choice we had.
>
> Yes, there is a difference between an optional parameter with a default
> value and one without.
>
> If you got a value QMP clients cannot send, the difference can be
> eliminated: just pass this value to stand for "nothing".  This is the
> case for pointers: just pass NULL.  Like everybody else does when
> passing "nothing".
>
> When "nothing" is to be interpreted just like a context-independent
> default value, then the difference doesn't matter.  The client doesn't
> care, and the function handling the message becomes simpler.
>
> Only when "nothing" can mean different things do you really need both
> have_FOO and FOO parameters.

Right, and I'm saying that we have cases like this (especially with
bools).  Unfortunately, there are places in the protocol that have
tristate values for bool parameters and the behavior is distinctly
different for false, true, and not-present.

So yes, we could special case those bits and use sentinel values for
everything else.  Just realize that we need to handle the above case.

> I can't see why we couldn't introduce default values into the schema if
> we wanted, and use them to simplify generated code.
>
> For pointers, we don't even need schema extensions to simplify away the
> silly have_FOOs.

Except you have to carefully audit all users to make sure of that.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
  2013-07-30 13:26           ` Anthony Liguori
@ 2013-07-30 15:22             ` Markus Armbruster
  0 siblings, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2013-07-30 15:22 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Juan Quintela, Pawit Pornkitprasan, qemu-devel, Ryousei Takano,
	Luiz Capitulino

Anthony Liguori <anthony@codemonkey.ws> writes:

> On Tue, Jul 30, 2013 at 1:39 AM, Markus Armbruster <armbru@redhat.com> wrote:
>> Anthony Liguori <anthony@codemonkey.ws> writes:
>>
>>> This was part of the discussion way back when this all was first
>>> introduced.  Since everything was open coded and we had to preserve
>>> the semantics, that was the only choice we had.
>>
>> Yes, there is a difference between an optional parameter with a default
>> value and one without.
>>
>> If you got a value QMP clients cannot send, the difference can be
>> eliminated: just pass this value to stand for "nothing".  This is the
>> case for pointers: just pass NULL.  Like everybody else does when
>> passing "nothing".
>>
>> When "nothing" is to be interpreted just like a context-independent
>> default value, then the difference doesn't matter.  The client doesn't
>> care, and the function handling the message becomes simpler.
>>
>> Only when "nothing" can mean different things do you really need both
>> have_FOO and FOO parameters.
>
> Right, and I'm saying that we have cases like this (especially with
> bools).  Unfortunately, there are places in the protocol that have

No argument there.

> tristate values for bool parameters and the behavior is distinctly
> different for false, true, and not-present.
>
> So yes, we could special case those bits and use sentinel values for
> everything else.  Just realize that we need to handle the above case.

Yes, we do, and it's understandable that only the most general case got
implemented.

>> I can't see why we couldn't introduce default values into the schema if
>> we wanted, and use them to simplify generated code.
>>
>> For pointers, we don't even need schema extensions to simplify away the
>> silly have_FOOs.
>
> Except you have to carefully audit all users to make sure of that.

For pointers, the audit should be trivial: change generator to omit the
have_FOO, compile, fix up the compile errors (drop have_FOO arguments,
replace have_FOO tests be FOO tests), done.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-07-30 15:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-19  2:36 [Qemu-devel] [PATCH] migration: don't use uninitialized variables Pawit Pornkitprasan
2013-07-19 10:57 ` Eric Blake
2013-07-19 11:04   ` Pawit Pornkitprasan
2013-07-19 11:13     ` Eric Blake
2013-07-29 21:05   ` Luiz Capitulino
2013-07-30  0:15     ` Markus Armbruster
2013-07-30  1:29       ` Anthony Liguori
2013-07-30  6:39         ` Markus Armbruster
2013-07-30 13:26           ` Anthony Liguori
2013-07-30 15:22             ` Markus Armbruster
2013-07-22  7:32 ` Orit Wasserman
2013-07-29 20:52 ` Luiz Capitulino
2013-07-29 23:29   ` Pawit Pornkitprasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).