Patchwork [v2,23/27] qdev: inline qdev_prop_set into qdev_prop_set_ptr

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 4, 2012, 8:02 a.m.
Message ID <1328342577-25732-24-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/139562/
State New
Headers show

Comments

Paolo Bonzini - Feb. 4, 2012, 8:02 a.m.
qdev_prop_set is not needed anymore except for hacks, simplify it and
inline it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c |   26 +++++++-------------------
 1 files changed, 7 insertions(+), 19 deletions(-)
Anthony Liguori - Feb. 6, 2012, 2:37 p.m.
On 02/04/2012 02:02 AM, Paolo Bonzini wrote:
> qdev_prop_set is not needed anymore except for hacks, simplify it and
> inline it.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/qdev-properties.c |   26 +++++++-------------------
>   1 files changed, 7 insertions(+), 19 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 5a11676..b3cd2a8 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -1115,24 +1115,6 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
>       return 0;
>   }
>
> -static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type)
> -{
> -    Property *prop;
> -
> -    prop = qdev_prop_find(dev, name);
> -    if (!prop) {
> -        fprintf(stderr, "%s: property \"%s.%s\" not found\n",
> -                __FUNCTION__, object_get_typename(OBJECT(dev)), name);
> -        abort();
> -    }
> -    if (prop->info->type != type) {
> -        fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n",
> -                __FUNCTION__, object_get_typename(OBJECT(dev)), name);
> -        abort();
> -    }
> -    qdev_prop_cpy(dev, prop, src);
> -}
> -
>   void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value)
>   {
>       Error *errp = NULL;
> @@ -1248,7 +1230,13 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)
>
>   void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
>   {
> -    qdev_prop_set(dev, name,&value, PROP_TYPE_PTR);
> +    Property *prop;
> +    void **ptr;
> +
> +    prop = qdev_prop_find(dev, name);
> +    assert(prop&&  prop->info ==&qdev_prop_ptr);
> +    ptr = qdev_get_prop_ptr(dev, prop);
> +    *ptr = value;
>   }
>
>   void qdev_prop_set_defaults(DeviceState *dev, Property *props)

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 5a11676..b3cd2a8 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1115,24 +1115,6 @@  int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
     return 0;
 }
 
-static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type)
-{
-    Property *prop;
-
-    prop = qdev_prop_find(dev, name);
-    if (!prop) {
-        fprintf(stderr, "%s: property \"%s.%s\" not found\n",
-                __FUNCTION__, object_get_typename(OBJECT(dev)), name);
-        abort();
-    }
-    if (prop->info->type != type) {
-        fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n",
-                __FUNCTION__, object_get_typename(OBJECT(dev)), name);
-        abort();
-    }
-    qdev_prop_cpy(dev, prop, src);
-}
-
 void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value)
 {
     Error *errp = NULL;
@@ -1248,7 +1230,13 @@  void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)
 
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
 {
-    qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
+    Property *prop;
+    void **ptr;
+
+    prop = qdev_prop_find(dev, name);
+    assert(prop && prop->info == &qdev_prop_ptr);
+    ptr = qdev_get_prop_ptr(dev, prop);
+    *ptr = value;
 }
 
 void qdev_prop_set_defaults(DeviceState *dev, Property *props)