diff mbox series

[v4,19/32] qdev: Avoid using prop->name unnecessarily

Message ID 20201211220529.2290218-20-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show
Series qdev property code cleanup | expand

Commit Message

Eduardo Habkost Dec. 11, 2020, 10:05 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.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
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

Igor Mammedov Dec. 14, 2020, 2:45 p.m. UTC | #1
On Fri, 11 Dec 2020 17:05:16 -0500
Eduardo Habkost <ehabkost@redhat.com> 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.
> 
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@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(-)
> 
> diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
> index 3973105658..a5d997e7dc 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 9cf9bcb39d..42529c3b65 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);
>  }
> @@ -966,7 +966,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,
> @@ -982,7 +982,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;
>      }
> @@ -1051,7 +1051,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,
> @@ -1067,7 +1067,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 7495798a66..50734a1cd4 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 3973105658..a5d997e7dc 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 9cf9bcb39d..42529c3b65 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);
 }
@@ -966,7 +966,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,
@@ -982,7 +982,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;
     }
@@ -1051,7 +1051,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,
@@ -1067,7 +1067,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 7495798a66..50734a1cd4 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,