[Qemu-devel] [PATCH 4/5] migration: Don't try to set *errp directly

Eduardo Habkost posted 5 patches 8 years, 5 months ago
[Qemu-devel] [PATCH 4/5] migration: Don't try to set *errp directly
Posted by Eduardo Habkost 8 years, 5 months ago
Assigning directly to *errp is not valid, as errp may be NULL,
&error_fatal, or &error_abort.  Use error_propagate() instead.

Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 migration/migration.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/migration.c b/migration/migration.c
index 48c94c9ca1..5a8bef3ef5 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1188,7 +1188,7 @@ bool migration_is_blocked(Error **errp)
     }
 
     if (migration_blockers) {
-        *errp = error_copy(migration_blockers->data);
+        error_propagate(errp, error_copy(migration_blockers->data));
         return true;
     }
 
-- 
2.11.0.259.g40922b1


Re: [Qemu-devel] [PATCH 4/5] migration: Don't try to set *errp directly
Posted by Juan Quintela 8 years, 5 months ago
Eduardo Habkost <ehabkost@redhat.com> wrote:
> Assigning directly to *errp is not valid, as errp may be NULL,
> &error_fatal, or &error_abort.  Use error_propagate() instead.
>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>


Reviewed-by: Juan Quintela <quintela@redhat.com>

queued

Thanks.


Re: [Qemu-devel] [PATCH 4/5] migration: Don't try to set *errp directly
Posted by Dr. David Alan Gilbert 8 years, 5 months ago
* Eduardo Habkost (ehabkost@redhat.com) wrote:
> Assigning directly to *errp is not valid, as errp may be NULL,
> &error_fatal, or &error_abort.  Use error_propagate() instead.
> 
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  migration/migration.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 48c94c9ca1..5a8bef3ef5 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1188,7 +1188,7 @@ bool migration_is_blocked(Error **errp)
>      }
>  
>      if (migration_blockers) {
> -        *errp = error_copy(migration_blockers->data);
> +        error_propagate(errp, error_copy(migration_blockers->data));
>          return true;
>      }

if errp is NULL doesn't that leak the error_copy ?

Dave

>  
> -- 
> 2.11.0.259.g40922b1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH 4/5] migration: Don't try to set *errp directly
Posted by Dr. David Alan Gilbert 8 years, 5 months ago
* Dr. David Alan Gilbert (dgilbert@redhat.com) wrote:
> * Eduardo Habkost (ehabkost@redhat.com) wrote:
> > Assigning directly to *errp is not valid, as errp may be NULL,
> > &error_fatal, or &error_abort.  Use error_propagate() instead.
> > 
> > Cc: Juan Quintela <quintela@redhat.com>
> > Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  migration/migration.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 48c94c9ca1..5a8bef3ef5 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -1188,7 +1188,7 @@ bool migration_is_blocked(Error **errp)
> >      }
> >  
> >      if (migration_blockers) {
> > -        *errp = error_copy(migration_blockers->data);
> > +        error_propagate(errp, error_copy(migration_blockers->data));
> >          return true;
> >      }
> 
> if errp is NULL doesn't that leak the error_copy ?

To answer myself, no it doesn't - error_propagate free's it in that
case.

Dave

> Dave
> 
> >  
> > -- 
> > 2.11.0.259.g40922b1
> > 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK