diff mbox series

[v2,18/44] qdev: Avoid using prop->name unnecessarily

Message ID 20201104160021.2342108-19-ehabkost@redhat.com
State New
Headers show
Series Make qdev static property API usable by any QOM type | expand

Commit Message

Eduardo Habkost Nov. 4, 2020, 3:59 p.m. UTC
We already get the property name as argument to the property
getter and setters, we don't need to use prop->name.  This will
make it easier to remove the Property.name field in the future.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This is a new patch added in series v2
---
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
 backends/tpm/tpm_util.c          |  2 +-
 hw/core/qdev-properties-system.c | 14 +++++++-------
 hw/core/qdev-properties.c        |  4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

Comments

Stefan Berger Nov. 4, 2020, 5:25 p.m. UTC | #1
On 11/4/20 10:59 AM, Eduardo Habkost wrote:
> We already get the property name as argument to the property
> getter and setters, we don't need to use prop->name.  This will
> make it easier to remove the Property.name field in the future.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>


> ---
> This is a new patch added in series v2
> ---
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>   backends/tpm/tpm_util.c          |  2 +-
>   hw/core/qdev-properties-system.c | 14 +++++++-------
>   hw/core/qdev-properties.c        |  4 ++--
>   3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
> index e91c21dd4a..dba2f6b04a 100644
> --- a/backends/tpm/tpm_util.c
> +++ b/backends/tpm/tpm_util.c
> @@ -63,7 +63,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
>       s = qemu_find_tpm_be(str);
>       if (s == NULL) {
>           error_setg(errp, "Property '%s.%s' can't find value '%s'",
> -                   object_get_typename(obj), prop->name, str);
> +                   object_get_typename(obj), name, str);
>       } else if (tpm_backend_init(s, TPM_IF(obj), errp) == 0) {
>           *be = s; /* weak reference, avoid cyclic ref */
>       }
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index 808e7136a0..202abd0e4b 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -141,7 +141,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
>       }
>       if (!blk) {
>           error_setg(errp, "Property '%s.%s' can't find value '%s'",
> -                   object_get_typename(OBJECT(dev)), prop->name, str);
> +                   object_get_typename(OBJECT(dev)), name, str);
>           goto fail;
>       }
>       if (blk_attach_dev(blk, dev) < 0) {
> @@ -262,10 +262,10 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
>       s = qemu_chr_find(str);
>       if (s == NULL) {
>           error_setg(errp, "Property '%s.%s' can't find value '%s'",
> -                   object_get_typename(obj), prop->name, str);
> +                   object_get_typename(obj), name, str);
>       } else if (!qemu_chr_fe_init(be, s, errp)) {
>           error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
> -                      object_get_typename(obj), prop->name, str);
> +                      object_get_typename(obj), name, str);
>       }
>       g_free(str);
>   }
> @@ -965,7 +965,7 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
>           abort();
>       }
>   
> -    visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp);
> +    visit_type_enum(v, name, &speed, prop->info->enum_table, errp);
>   }
>   
>   static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
> @@ -981,7 +981,7 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
>           return;
>       }
>   
> -    if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
> +    if (!visit_type_enum(v, name, &speed, prop->info->enum_table,
>                            errp)) {
>           return;
>       }
> @@ -1050,7 +1050,7 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
>           abort();
>       }
>   
> -    visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp);
> +    visit_type_enum(v, name, &width, prop->info->enum_table, errp);
>   }
>   
>   static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
> @@ -1066,7 +1066,7 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
>           return;
>       }
>   
> -    if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
> +    if (!visit_type_enum(v, name, &width, prop->info->enum_table,
>                            errp)) {
>           return;
>       }
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index a7bbc1235a..69181ce31d 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -50,7 +50,7 @@ void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name,
>       Property *prop = opaque;
>       int *ptr = qdev_get_prop_ptr(obj, prop);
>   
> -    visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
> +    visit_type_enum(v, name, ptr, prop->info->enum_table, errp);
>   }
>   
>   void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
> @@ -65,7 +65,7 @@ void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
>           return;
>       }
>   
> -    visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
> +    visit_type_enum(v, name, ptr, prop->info->enum_table, errp);
>   }
>   
>   void qdev_propinfo_set_default_value_enum(ObjectProperty *op,
diff mbox series

Patch

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index e91c21dd4a..dba2f6b04a 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -63,7 +63,7 @@  static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
     s = qemu_find_tpm_be(str);
     if (s == NULL) {
         error_setg(errp, "Property '%s.%s' can't find value '%s'",
-                   object_get_typename(obj), prop->name, str);
+                   object_get_typename(obj), name, str);
     } else if (tpm_backend_init(s, TPM_IF(obj), errp) == 0) {
         *be = s; /* weak reference, avoid cyclic ref */
     }
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 808e7136a0..202abd0e4b 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -141,7 +141,7 @@  static void set_drive_helper(Object *obj, Visitor *v, const char *name,
     }
     if (!blk) {
         error_setg(errp, "Property '%s.%s' can't find value '%s'",
-                   object_get_typename(OBJECT(dev)), prop->name, str);
+                   object_get_typename(OBJECT(dev)), name, str);
         goto fail;
     }
     if (blk_attach_dev(blk, dev) < 0) {
@@ -262,10 +262,10 @@  static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
     s = qemu_chr_find(str);
     if (s == NULL) {
         error_setg(errp, "Property '%s.%s' can't find value '%s'",
-                   object_get_typename(obj), prop->name, str);
+                   object_get_typename(obj), name, str);
     } else if (!qemu_chr_fe_init(be, s, errp)) {
         error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
-                      object_get_typename(obj), prop->name, str);
+                      object_get_typename(obj), name, str);
     }
     g_free(str);
 }
@@ -965,7 +965,7 @@  static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
         abort();
     }
 
-    visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp);
+    visit_type_enum(v, name, &speed, prop->info->enum_table, errp);
 }
 
 static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
@@ -981,7 +981,7 @@  static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
         return;
     }
 
-    if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
+    if (!visit_type_enum(v, name, &speed, prop->info->enum_table,
                          errp)) {
         return;
     }
@@ -1050,7 +1050,7 @@  static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
         abort();
     }
 
-    visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp);
+    visit_type_enum(v, name, &width, prop->info->enum_table, errp);
 }
 
 static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
@@ -1066,7 +1066,7 @@  static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
         return;
     }
 
-    if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
+    if (!visit_type_enum(v, name, &width, prop->info->enum_table,
                          errp)) {
         return;
     }
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a7bbc1235a..69181ce31d 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -50,7 +50,7 @@  void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name,
     Property *prop = opaque;
     int *ptr = qdev_get_prop_ptr(obj, prop);
 
-    visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
+    visit_type_enum(v, name, ptr, prop->info->enum_table, errp);
 }
 
 void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
@@ -65,7 +65,7 @@  void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
         return;
     }
 
-    visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
+    visit_type_enum(v, name, ptr, prop->info->enum_table, errp);
 }
 
 void qdev_propinfo_set_default_value_enum(ObjectProperty *op,