mirror of https://github.com/xemu-project/xemu.git
qom: Detect attempts to add a property that already exists
Detect attempts to add a property to an object if one of that name already exists, and report them as errors. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1364217314-7400-2-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
b000dfbd42
commit
54852b0371
13
qom/object.c
13
qom/object.c
|
@ -629,7 +629,18 @@ void object_property_add(Object *obj, const char *name, const char *type,
|
||||||
ObjectPropertyRelease *release,
|
ObjectPropertyRelease *release,
|
||||||
void *opaque, Error **errp)
|
void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
ObjectProperty *prop = g_malloc0(sizeof(*prop));
|
ObjectProperty *prop;
|
||||||
|
|
||||||
|
QTAILQ_FOREACH(prop, &obj->properties, node) {
|
||||||
|
if (strcmp(prop->name, name) == 0) {
|
||||||
|
error_setg(errp, "attempt to add duplicate property '%s'"
|
||||||
|
" to object (type '%s')", name,
|
||||||
|
object_get_typename(obj));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prop = g_malloc0(sizeof(*prop));
|
||||||
|
|
||||||
prop->name = g_strdup(name);
|
prop->name = g_strdup(name);
|
||||||
prop->type = g_strdup(type);
|
prop->type = g_strdup(type);
|
||||||
|
|
Loading…
Reference in New Issue