Introduce an intermediary boolean prop_already_exists into 
object_class_property_add()
so that it is obvious to a developer if they inadvertantly introduce a duplicate
class property:

qemu-system-x86_64: ../qom/object.c:1417: object_class_property_add:
  Assertion `!prop_already_exists' failed.

Signed-off-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Daniel P. BerrangĂ© <[email protected]>
Message-ID: <[email protected]>
---
 qom/object.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 41b1ec81d4..914d1228ca 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1410,9 +1410,10 @@ object_class_property_add(ObjectClass *klass,
                           ObjectPropertyRelease *release,
                           void *opaque)
 {
+    bool prop_already_exists = object_class_property_find(klass, name);
     ObjectProperty *prop;
 
-    assert(!object_class_property_find(klass, name));
+    assert(!prop_already_exists);
 
     prop = g_malloc0(sizeof(*prop));
 
-- 
2.43.0


Reply via email to