diff mbox

[04/10] qdev: Use error_prepend() for errors applying globals

Message ID 1466022773-8965-5-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost June 15, 2016, 8:32 p.m. UTC
The same Error* will be used in an error_propagate() call in the
future, so prepend a "can't apply global" prefix to it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/qdev-properties.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Markus Armbruster June 20, 2016, 8:02 a.m. UTC | #1
Eduardo Habkost <ehabkost@redhat.com> writes:

> The same Error* will be used in an error_propagate() call in the
> future, so prepend a "can't apply global" prefix to it.

What future?  A future patch?

> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/core/qdev-properties.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 64e17aa..cd19603 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1079,8 +1079,9 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
>          object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
>          if (err != NULL) {
>              assert(prop->user_provided);
> -            error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
> -                              prop->driver, prop->property, prop->value);
> +            error_prepend(&err, "can't apply global %s.%s=%s: ",
> +                          prop->driver, prop->property, prop->value);
> +            error_reportf_err(err, "Warning: ");
>          }
>      }
>  }

You reword the error message.  Should be mentioned in the commit
message.

Why do you need to prepend the "Warning: ..." in two steps, first
error_prepend() for the "...", then error_reportf_err() for "Warning: "?
Perhaps it'll become clear later in the series, but it's not obvious
now.
Eduardo Habkost June 20, 2016, 1:43 p.m. UTC | #2
On Mon, Jun 20, 2016 at 10:02:38AM +0200, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > The same Error* will be used in an error_propagate() call in the
> > future, so prepend a "can't apply global" prefix to it.
> 
> What future?  A future patch?
> 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  hw/core/qdev-properties.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > index 64e17aa..cd19603 100644
> > --- a/hw/core/qdev-properties.c
> > +++ b/hw/core/qdev-properties.c
> > @@ -1079,8 +1079,9 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
> >          object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> >          if (err != NULL) {
> >              assert(prop->user_provided);
> > -            error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
> > -                              prop->driver, prop->property, prop->value);
> > +            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > +                          prop->driver, prop->property, prop->value);
> > +            error_reportf_err(err, "Warning: ");
> >          }
> >      }
> >  }
> 
> You reword the error message.  Should be mentioned in the commit
> message.

Will mention in in the commit message in v2.

> 
> Why do you need to prepend the "Warning: ..." in two steps, first
> error_prepend() for the "...", then error_reportf_err() for "Warning: "?
> Perhaps it'll become clear later in the series, but it's not obvious
> now.

The split is useful for patch 05/10. I will squash both patches,
as you suggested in another message.

Thanks!
diff mbox

Patch

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 64e17aa..cd19603 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1079,8 +1079,9 @@  static void qdev_prop_set_globals_for_type(DeviceState *dev,
         object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
         if (err != NULL) {
             assert(prop->user_provided);
-            error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
-                              prop->driver, prop->property, prop->value);
+            error_prepend(&err, "can't apply global %s.%s=%s: ",
+                          prop->driver, prop->property, prop->value);
+            error_reportf_err(err, "Warning: ");
         }
     }
 }