mirror of https://gitee.com/openkylin/qemu.git
qom: Push error reporting to object_property_find()
Avoids duplicated error_set(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Also drop error_set() in object_property_del().] Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
8cb6789a31
commit
89bfe00043
|
@ -323,7 +323,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
|
|||
if (nd->netdev)
|
||||
qdev_prop_set_netdev(dev, "netdev", nd->netdev);
|
||||
if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
|
||||
object_property_find(OBJECT(dev), "vectors")) {
|
||||
object_property_find(OBJECT(dev), "vectors", NULL)) {
|
||||
qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
|
||||
}
|
||||
nd->instantiated = 1;
|
||||
|
|
|
@ -214,7 +214,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
|
|||
if (bootindex >= 0) {
|
||||
qdev_prop_set_int32(dev, "bootindex", bootindex);
|
||||
}
|
||||
if (object_property_find(OBJECT(dev), "removable")) {
|
||||
if (object_property_find(OBJECT(dev), "removable", NULL)) {
|
||||
qdev_prop_set_bit(dev, "removable", removable);
|
||||
}
|
||||
if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
|
||||
|
|
|
@ -639,10 +639,12 @@ void object_property_del(Object *obj, const char *name, struct Error **errp);
|
|||
* object_property_find:
|
||||
* @obj: the object
|
||||
* @name: the name of the property
|
||||
* @errp: returns an error if this function fails
|
||||
*
|
||||
* Look up a property for an object and return its #ObjectProperty if found.
|
||||
*/
|
||||
ObjectProperty *object_property_find(Object *obj, const char *name);
|
||||
ObjectProperty *object_property_find(Object *obj, const char *name,
|
||||
struct Error **errp);
|
||||
|
||||
void object_unparent(Object *obj);
|
||||
|
||||
|
|
22
qom/object.c
22
qom/object.c
|
@ -672,7 +672,8 @@ void object_property_add(Object *obj, const char *name, const char *type,
|
|||
QTAILQ_INSERT_TAIL(&obj->properties, prop, node);
|
||||
}
|
||||
|
||||
ObjectProperty *object_property_find(Object *obj, const char *name)
|
||||
ObjectProperty *object_property_find(Object *obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
ObjectProperty *prop;
|
||||
|
||||
|
@ -682,15 +683,14 @@ ObjectProperty *object_property_find(Object *obj, const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void object_property_del(Object *obj, const char *name, Error **errp)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(obj, name);
|
||||
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
if (prop == NULL) {
|
||||
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -708,10 +708,8 @@ void object_property_del(Object *obj, const char *name, Error **errp)
|
|||
void object_property_get(Object *obj, Visitor *v, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(obj, name);
|
||||
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
if (prop == NULL) {
|
||||
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -725,10 +723,8 @@ void object_property_get(Object *obj, Visitor *v, const char *name,
|
|||
void object_property_set(Object *obj, Visitor *v, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(obj, name);
|
||||
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
if (prop == NULL) {
|
||||
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -881,10 +877,8 @@ char *object_property_print(Object *obj, const char *name,
|
|||
|
||||
const char *object_property_get_type(Object *obj, const char *name, Error **errp)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(obj, name);
|
||||
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
if (prop == NULL) {
|
||||
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1061,7 @@ gchar *object_get_canonical_path(Object *obj)
|
|||
|
||||
Object *object_resolve_path_component(Object *parent, gchar *part)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(parent, part);
|
||||
ObjectProperty *prop = object_property_find(parent, part, NULL);
|
||||
if (prop == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue