Message ID | 20201211220529.2290218-26-ehabkost@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | qdev property code cleanup | expand |
On Fri, 11 Dec 2020 17:05:22 -0500 Eduardo Habkost <ehabkost@redhat.com> wrote: > Support Property.set_default and PropertyInfo.description even if > PropertyInfo.create is set. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes v1 -> v2: > * Patch redone after changes in the previous patches in the > series > --- > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: "Daniel P. Berrangé" <berrange@redhat.com> > Cc: Eduardo Habkost <ehabkost@redhat.com> > Cc: qemu-devel@nongnu.org > --- > hw/core/qdev-properties.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c > index 3bb05e7d0d..fcda0c8f4b 100644 > --- a/hw/core/qdev-properties.c > +++ b/hw/core/qdev-properties.c > @@ -863,24 +863,25 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name, > Property *prop) > { > ObjectClass *oc = OBJECT_CLASS(klass); > + ObjectProperty *op; > > if (prop->info->create) { > - prop->info->create(oc, name, prop); > + op = prop->info->create(oc, name, prop); > } else { > - ObjectProperty *op; > - > op = object_class_property_add(oc, > name, prop->info->name, > field_prop_getter(prop->info), > field_prop_setter(prop->info), > prop->info->release, > prop); > - if (prop->set_default) { > - prop->info->set_default_value(op, prop); > - } > } > - object_class_property_set_description(oc, name, > - prop->info->description); > + if (prop->set_default) { > + prop->info->set_default_value(op, prop); > + } > + if (prop->info->description) { before that, null description wasn't allow, why relax rule now? > + object_class_property_set_description(oc, name, > + prop->info->description); > + } > } > > /**
On Mon, Dec 14, 2020 at 04:00:59PM +0100, Igor Mammedov wrote: > On Fri, 11 Dec 2020 17:05:22 -0500 > Eduardo Habkost <ehabkost@redhat.com> wrote: > > > Support Property.set_default and PropertyInfo.description even if > > PropertyInfo.create is set. > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > --- > > Changes v1 -> v2: > > * Patch redone after changes in the previous patches in the > > series > > --- > > Cc: Paolo Bonzini <pbonzini@redhat.com> > > Cc: "Daniel P. Berrangé" <berrange@redhat.com> > > Cc: Eduardo Habkost <ehabkost@redhat.com> > > Cc: qemu-devel@nongnu.org > > --- > > hw/core/qdev-properties.c | 17 +++++++++-------- > > 1 file changed, 9 insertions(+), 8 deletions(-) > > > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c > > index 3bb05e7d0d..fcda0c8f4b 100644 > > --- a/hw/core/qdev-properties.c > > +++ b/hw/core/qdev-properties.c > > @@ -863,24 +863,25 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name, > > Property *prop) > > { > > ObjectClass *oc = OBJECT_CLASS(klass); > > + ObjectProperty *op; > > > > if (prop->info->create) { > > - prop->info->create(oc, name, prop); > > + op = prop->info->create(oc, name, prop); > > } else { > > - ObjectProperty *op; > > - > > op = object_class_property_add(oc, > > name, prop->info->name, > > field_prop_getter(prop->info), > > field_prop_setter(prop->info), > > prop->info->release, > > prop); > > - if (prop->set_default) { > > - prop->info->set_default_value(op, prop); > > - } > > } > > - object_class_property_set_description(oc, name, > > - prop->info->description); > > + if (prop->set_default) { > > + prop->info->set_default_value(op, prop); > > + } > > > + if (prop->info->description) { > before that, null description wasn't allow, why relax rule now? NULL description was already allowed before, because object_class_property_set_description(..., NULL) works. This means the conditional I've added above is completely unnecessary. I will fix this in the next version. Thanks! > > > + object_class_property_set_description(oc, name, > > + prop->info->description); > > + } > > } > > > > /** >
On Mon, 14 Dec 2020 13:28:10 -0500 Eduardo Habkost <ehabkost@redhat.com> wrote: > On Mon, Dec 14, 2020 at 04:00:59PM +0100, Igor Mammedov wrote: > > On Fri, 11 Dec 2020 17:05:22 -0500 > > Eduardo Habkost <ehabkost@redhat.com> wrote: > > > > > Support Property.set_default and PropertyInfo.description even if > > > PropertyInfo.create is set. > > > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > > --- > > > Changes v1 -> v2: > > > * Patch redone after changes in the previous patches in the > > > series > > > --- > > > Cc: Paolo Bonzini <pbonzini@redhat.com> > > > Cc: "Daniel P. Berrangé" <berrange@redhat.com> > > > Cc: Eduardo Habkost <ehabkost@redhat.com> > > > Cc: qemu-devel@nongnu.org > > > --- > > > hw/core/qdev-properties.c | 17 +++++++++-------- > > > 1 file changed, 9 insertions(+), 8 deletions(-) > > > > > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c > > > index 3bb05e7d0d..fcda0c8f4b 100644 > > > --- a/hw/core/qdev-properties.c > > > +++ b/hw/core/qdev-properties.c > > > @@ -863,24 +863,25 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name, > > > Property *prop) > > > { > > > ObjectClass *oc = OBJECT_CLASS(klass); > > > + ObjectProperty *op; > > > > > > if (prop->info->create) { > > > - prop->info->create(oc, name, prop); > > > + op = prop->info->create(oc, name, prop); > > > } else { > > > - ObjectProperty *op; > > > - > > > op = object_class_property_add(oc, > > > name, prop->info->name, > > > field_prop_getter(prop->info), > > > field_prop_setter(prop->info), > > > prop->info->release, > > > prop); > > > - if (prop->set_default) { > > > - prop->info->set_default_value(op, prop); > > > - } > > > } > > > - object_class_property_set_description(oc, name, > > > - prop->info->description); > > > + if (prop->set_default) { > > > + prop->info->set_default_value(op, prop); > > > + } > > > > > + if (prop->info->description) { > > before that, null description wasn't allow, why relax rule now? > > NULL description was already allowed before, because > object_class_property_set_description(..., NULL) works. > > This means the conditional I've added above is completely > unnecessary. I will fix this in the next version. Thanks! ok, either way Reviewed-by: Igor Mammedov <imammedo@redhat.com> > > > > > > + object_class_property_set_description(oc, name, > > > + prop->info->description); > > > + } > > > } > > > > > > /** > > >
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 3bb05e7d0d..fcda0c8f4b 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -863,24 +863,25 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name, Property *prop) { ObjectClass *oc = OBJECT_CLASS(klass); + ObjectProperty *op; if (prop->info->create) { - prop->info->create(oc, name, prop); + op = prop->info->create(oc, name, prop); } else { - ObjectProperty *op; - op = object_class_property_add(oc, name, prop->info->name, field_prop_getter(prop->info), field_prop_setter(prop->info), prop->info->release, prop); - if (prop->set_default) { - prop->info->set_default_value(op, prop); - } } - object_class_property_set_description(oc, name, - prop->info->description); + if (prop->set_default) { + prop->info->set_default_value(op, prop); + } + if (prop->info->description) { + object_class_property_set_description(oc, name, + prop->info->description); + } } /**
Support Property.set_default and PropertyInfo.description even if PropertyInfo.create is set. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes v1 -> v2: * Patch redone after changes in the previous patches in the series --- Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)