diff options
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 5 | ||||
-rw-r--r-- | qom/qom-qmp-cmds.c | 17 |
2 files changed, 9 insertions, 13 deletions
diff --git a/qom/object.c b/qom/object.c index 75a78c9343..f2ae6e6b2a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1196,11 +1196,11 @@ object_property_try_add(Object *obj, const char *name, const char *type, if (name_len >= 3 && !memcmp(name + name_len - 3, "[*]", 4)) { int i; - ObjectProperty *ret; + ObjectProperty *ret = NULL; char *name_no_array = g_strdup(name); name_no_array[name_len - 3] = '\0'; - for (i = 0; ; ++i) { + for (i = 0; i < INT16_MAX; ++i) { char *full_name = g_strdup_printf("%s[%d]", name_no_array, i); ret = object_property_try_add(obj, full_name, type, get, set, @@ -1211,6 +1211,7 @@ object_property_try_add(Object *obj, const char *name, const char *type, } } g_free(name_no_array); + assert(ret); return ret; } diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 310ab2d048..2dd233f293 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -138,15 +138,10 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, return NULL; } - klass = object_class_dynamic_cast(klass, TYPE_DEVICE); - if (klass == NULL) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_DEVICE); - return NULL; - } - - if (object_class_is_abstract(klass)) { + if (!object_class_dynamic_cast(klass, TYPE_DEVICE) + || object_class_is_abstract(klass)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", - "non-abstract device type"); + "a non-abstract device type"); return NULL; } @@ -208,9 +203,9 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, return NULL; } - klass = object_class_dynamic_cast(klass, TYPE_OBJECT); - if (klass == NULL) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_OBJECT); + if (!object_class_dynamic_cast(klass, TYPE_OBJECT)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", + "a QOM type"); return NULL; } |