diff --git a/qemu/qapi/qobject-input-visitor.c b/qemu/qapi/qobject-input-visitor.c index 5f04400c..1018935a 100644 --- a/qemu/qapi/qobject-input-visitor.c +++ b/qemu/qapi/qobject-input-visitor.c @@ -129,7 +129,7 @@ static QObject *qobject_input_try_get_object(QObjectInputVisitor *qiv, if (qobject_type(qobj) == QTYPE_QDICT) { assert(name); - ret = qdict_get(qobject_to_qdict(qobj), name); + ret = qdict_get(qobject_to(QDict, qobj), name); if (tos->h && consume && ret) { bool removed = g_hash_table_remove(tos->h, name); assert(removed); @@ -185,11 +185,11 @@ static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv, if (qobject_type(obj) == QTYPE_QDICT) { h = g_hash_table_new(g_str_hash, g_str_equal); - qdict_iter(qobject_to_qdict(obj), qdict_add_key, h); + qdict_iter(qobject_to(QDict, obj), qdict_add_key, h); tos->h = h; } else { assert(qobject_type(obj) == QTYPE_QLIST); - tos->entry = qlist_first(qobject_to_qlist(obj)); + tos->entry = qlist_first(qobject_to(QList, obj)); tos->index = -1; } @@ -353,7 +353,7 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj, if (!qobj) { return; } - qnum = qobject_to_qnum(qobj); + qnum = qobject_to(QNum, qobj); if (!qnum || !qnum_get_try_int(qnum, obj)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "integer"); @@ -371,7 +371,7 @@ static void qobject_input_type_uint64(Visitor *v, const char *name, uint64_t *ob if (!qobj) { return; } - qnum = qobject_to_qnum(qobj); + qnum = qobject_to(QNum, qobj); if (!qnum) { goto err; } @@ -401,7 +401,7 @@ static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj, if (!qobj) { return; } - qbool = qobject_to_qbool(qobj); + qbool = qobject_to(QBool, qobj); if (!qbool) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "boolean"); @@ -422,7 +422,7 @@ static void qobject_input_type_str(Visitor *v, const char *name, char **obj, if (!qobj) { return; } - qstr = qobject_to_qstring(qobj); + qstr = qobject_to(QString, qobj); if (!qstr) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "string"); @@ -442,7 +442,7 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj, if (!qobj) { return; } - qnum = qobject_to_qnum(qobj); + qnum = qobject_to(QNum, qobj); if (!qnum) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "number"); diff --git a/qemu/qapi/qobject-output-visitor.c b/qemu/qapi/qobject-output-visitor.c index ba1bac73..d71b0b13 100644 --- a/qemu/qapi/qobject-output-visitor.c +++ b/qemu/qapi/qobject-output-visitor.c @@ -95,11 +95,11 @@ static void qobject_output_add_obj(QObjectOutputVisitor *qov, const char *name, switch (qobject_type(cur)) { case QTYPE_QDICT: assert(name); - qdict_put_obj(qobject_to_qdict(cur), name, value); + qdict_put_obj(qobject_to(QDict, cur), name, value); break; case QTYPE_QLIST: assert(!name); - qlist_append_obj(qobject_to_qlist(cur), value); + qlist_append_obj(qobject_to(QList, cur), value); break; default: g_assert_not_reached(); diff --git a/qemu/qobject/qbool.c b/qemu/qobject/qbool.c index e5a7a538..5be6277c 100644 --- a/qemu/qobject/qbool.c +++ b/qemu/qobject/qbool.c @@ -55,7 +55,7 @@ QBool *qobject_to_qbool(const QObject *obj) */ bool qbool_is_equal(const QObject *x, const QObject *y) { - return qobject_to_qbool(x)->value == qobject_to_qbool(y)->value; + return qobject_to(QBool, x)->value == qobject_to(QBool, y)->value; } /** @@ -65,5 +65,5 @@ bool qbool_is_equal(const QObject *x, const QObject *y) void qbool_destroy_obj(QObject *obj) { assert(obj != NULL); - g_free(qobject_to_qbool(obj)); + g_free(qobject_to(QBool, obj)); } diff --git a/qemu/qobject/qdict.c b/qemu/qobject/qdict.c index 7c70bc90..2f268b3b 100644 --- a/qemu/qobject/qdict.c +++ b/qemu/qobject/qdict.c @@ -206,7 +206,7 @@ size_t qdict_size(const QDict *qdict) */ double qdict_get_double(const QDict *qdict, const char *key) { - return qnum_get_double(qobject_to_qnum(qdict_get(qdict, key))); + return qnum_get_double(qobject_to(QNum, qdict_get(qdict, key))); } /** @@ -219,7 +219,7 @@ double qdict_get_double(const QDict *qdict, const char *key) */ int64_t qdict_get_int(const QDict *qdict, const char *key) { - return qnum_get_int(qobject_to_qnum(qdict_get(qdict, key))); + return qnum_get_int(qobject_to(QNum, qdict_get(qdict, key))); } /** @@ -232,7 +232,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key) */ bool qdict_get_bool(const QDict *qdict, const char *key) { - return qbool_get_bool(qobject_to_qbool(qdict_get(qdict, key))); + return qbool_get_bool(qobject_to(QBool, qdict_get(qdict, key))); } /** @@ -240,7 +240,7 @@ bool qdict_get_bool(const QDict *qdict, const char *key) */ QList *qdict_get_qlist(const QDict *qdict, const char *key) { - return qobject_to_qlist(qdict_get(qdict, key)); + return qobject_to(QList, qdict_get(qdict, key)); } /** @@ -248,7 +248,7 @@ QList *qdict_get_qlist(const QDict *qdict, const char *key) */ QDict *qdict_get_qdict(const QDict *qdict, const char *key) { - return qobject_to_qdict(qdict_get(qdict, key)); + return qobject_to(QDict, qdict_get(qdict, key)); } /** @@ -262,7 +262,7 @@ QDict *qdict_get_qdict(const QDict *qdict, const char *key) */ const char *qdict_get_str(const QDict *qdict, const char *key) { - return qstring_get_str(qobject_to_qstring(qdict_get(qdict, key))); + return qstring_get_str(qobject_to(QString, qdict_get(qdict, key))); } /** @@ -275,7 +275,7 @@ const char *qdict_get_str(const QDict *qdict, const char *key) int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) { - QNum *qnum = qobject_to_qnum(qdict_get(qdict, key)); + QNum *qnum = qobject_to(QNum, qdict_get(qdict, key)); int64_t val; if (!qnum || !qnum_get_try_int(qnum, &val)) { @@ -294,7 +294,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key, */ bool qdict_get_try_bool(const QDict *qdict, const char *key, int def_value) { - QBool *qbool = qobject_to_qbool(qdict_get(qdict, key)); + QBool *qbool = qobject_to(QBool, qdict_get(qdict, key)); return qbool ? qbool_get_bool(qbool) : def_value; } @@ -309,7 +309,7 @@ bool qdict_get_try_bool(const QDict *qdict, const char *key, int def_value) */ const char *qdict_get_try_str(const QDict *qdict, const char *key) { - QString *qstr = qobject_to_qstring(qdict_get(qdict, key)); + QString *qstr = qobject_to(QString, qdict_get(qdict, key)); return qstr ? qstring_get_str(qstr) : NULL; } @@ -432,8 +432,8 @@ void qdict_del(QDict *qdict, const char *key) */ bool qdict_is_equal(const QObject *x, const QObject *y) { - const QDict *dict_x = qobject_to_qdict(x); - const QDict *dict_y = qobject_to_qdict(y); + const QDict *dict_x = qobject_to(QDict, x); + const QDict *dict_y = qobject_to(QDict, y); const QDictEntry *e; if (qdict_size(dict_x) != qdict_size(dict_y)) { @@ -461,7 +461,7 @@ void qdict_destroy_obj(QObject *obj) QDict *qdict; assert(obj != NULL); - qdict = qobject_to_qdict(obj); + qdict = qobject_to(QDict, obj); for (i = 0; i < QDICT_BUCKET_MAX; i++) { QDictEntry *entry = QLIST_FIRST(&qdict->table[i]); @@ -499,9 +499,9 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix) new_key = g_strdup_printf("%s.%i", prefix, i); if (qobject_type(value) == QTYPE_QDICT) { - qdict_flatten_qdict(qobject_to_qdict(value), target, new_key); + qdict_flatten_qdict(qobject_to(QDict, value), target, new_key); } else if (qobject_type(value) == QTYPE_QLIST) { - qdict_flatten_qlist(qobject_to_qlist(value), target, new_key); + qdict_flatten_qlist(qobject_to(QList, value), target, new_key); } else { /* All other types are moved to the target unchanged. */ qobject_incref(value); @@ -535,11 +535,11 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix) if (qobject_type(value) == QTYPE_QDICT) { /* Entries of QDicts are processed recursively, the QDict object * itself disappears. */ - qdict_flatten_qdict(qobject_to_qdict(value), target, + qdict_flatten_qdict(qobject_to(QDict, value), target, new_key ? new_key : entry->key); delete = true; } else if (qobject_type(value) == QTYPE_QLIST) { - qdict_flatten_qlist(qobject_to_qlist(value), target, + qdict_flatten_qlist(qobject_to(QList, value), target, new_key ? new_key : entry->key); delete = true; } else if (prefix) { @@ -900,7 +900,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) qdict_put_obj(two_level, prefix, child); } qobject_incref(ent->value); - qdict_put_obj(qobject_to_qdict(child), suffix, ent->value); + qdict_put_obj(qobject_to(QDict, child), suffix, ent->value); } else { if (child) { error_setg(errp, "Key %s prefix is already set as a dict", @@ -922,7 +922,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) ent = qdict_next(two_level, ent)) { if (qobject_type(ent->value) == QTYPE_QDICT) { - child = qdict_crumple(qobject_to_qdict(ent->value), errp); + child = qdict_crumple(qobject_to(QDict, ent->value), errp); if (!child) { goto error; } @@ -957,7 +957,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) } qobject_incref(child); - qlist_append_obj(qobject_to_qlist(dst), child); + qlist_append_obj(qobject_to(QList, dst), child); } QDECREF(multi_level); multi_level = NULL; diff --git a/qemu/qobject/qlist.c b/qemu/qobject/qlist.c index e6da9995..ad40fbce 100644 --- a/qemu/qobject/qlist.c +++ b/qemu/qobject/qlist.c @@ -176,8 +176,8 @@ QList *qobject_to_qlist(const QObject *obj) */ bool qlist_is_equal(const QObject *x, const QObject *y) { - const QList *list_x = qobject_to_qlist(x); - const QList *list_y = qobject_to_qlist(y); + const QList *list_x = qobject_to(QList, x); + const QList *list_y = qobject_to(QList, y); const QListEntry *entry_x, *entry_y; entry_x = qlist_first(list_x); @@ -206,7 +206,7 @@ void qlist_destroy_obj(QObject *obj) QListEntry *entry, *next_entry; assert(obj != NULL); - qlist = qobject_to_qlist(obj); + qlist = qobject_to(QList, obj); QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) { QTAILQ_REMOVE(&qlist->head, entry, next); diff --git a/qemu/qobject/qlit.c b/qemu/qobject/qlit.c index 4dcf0fcd..46acdf03 100644 --- a/qemu/qobject/qlit.c +++ b/qemu/qobject/qlit.c @@ -70,16 +70,16 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) switch (lhs->type) { case QTYPE_QBOOL: - return lhs->value.qbool == qbool_get_bool(qobject_to_qbool(rhs)); + return lhs->value.qbool == qbool_get_bool(qobject_to(QBool, rhs)); case QTYPE_QNUM: - return lhs->value.qnum == qnum_get_int(qobject_to_qnum(rhs)); + return lhs->value.qnum == qnum_get_int(qobject_to(QNum, rhs)); case QTYPE_QSTRING: return (strcmp(lhs->value.qstr, - qstring_get_str(qobject_to_qstring(rhs))) == 0); + qstring_get_str(qobject_to(QString, rhs))) == 0); case QTYPE_QDICT: - return qlit_equal_qdict(lhs, qobject_to_qdict(rhs)); + return qlit_equal_qdict(lhs, qobject_to(QDict, rhs)); case QTYPE_QLIST: - return qlit_equal_qlist(lhs, qobject_to_qlist(rhs)); + return qlit_equal_qlist(lhs, qobject_to(QList, rhs)); case QTYPE_QNULL: return true; default: diff --git a/qemu/qobject/qnum.c b/qemu/qobject/qnum.c index 60c395c1..ea091cfa 100644 --- a/qemu/qobject/qnum.c +++ b/qemu/qobject/qnum.c @@ -221,8 +221,8 @@ QNum *qobject_to_qnum(const QObject *obj) */ bool qnum_is_equal(const QObject *x, const QObject *y) { - QNum *num_x = qobject_to_qnum(x); - QNum *num_y = qobject_to_qnum(y); + QNum *num_x = qobject_to(QNum, x); + QNum *num_y = qobject_to(QNum, y); switch (num_x->kind) { case QNUM_I64: @@ -271,5 +271,5 @@ bool qnum_is_equal(const QObject *x, const QObject *y) void qnum_destroy_obj(QObject *obj) { assert(obj != NULL); - g_free(qobject_to_qnum(obj)); + g_free(qobject_to(QNum, obj)); } diff --git a/qemu/qobject/qstring.c b/qemu/qobject/qstring.c index 06f0da80..0a09895e 100644 --- a/qemu/qobject/qstring.c +++ b/qemu/qobject/qstring.c @@ -131,8 +131,8 @@ const char *qstring_get_str(const QString *qstring) */ bool qstring_is_equal(const QObject *x, const QObject *y) { - return !strcmp(qobject_to_qstring(x)->string, - qobject_to_qstring(y)->string); + return !strcmp(qobject_to(QString, x)->string, + qobject_to(QString, y)->string); } /** @@ -144,7 +144,7 @@ void qstring_destroy_obj(QObject *obj) QString *qs; assert(obj != NULL); - qs = qobject_to_qstring(obj); + qs = qobject_to(QString, obj); g_free(qs->string); g_free(qs); } diff --git a/qemu/qom/object.c b/qemu/qom/object.c index 306c5743..3553b63d 100644 --- a/qemu/qom/object.c +++ b/qemu/qom/object.c @@ -1014,7 +1014,7 @@ char *object_property_get_str(struct uc_struct *uc, Object *obj, const char *nam if (!ret) { return NULL; } - qstring = qobject_to_qstring(ret); + qstring = qobject_to(QString, ret); if (!qstring) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string"); retval = NULL; @@ -1075,7 +1075,7 @@ bool object_property_get_bool(struct uc_struct *uc, Object *obj, const char *nam if (!ret) { return false; } - qbool = qobject_to_qbool(ret); + qbool = qobject_to(QBool, ret); if (!qbool) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); retval = false; @@ -1107,7 +1107,7 @@ int64_t object_property_get_int(struct uc_struct *uc, Object *obj, const char *n return -1; } - qnum = qobject_to_qnum(ret); + qnum = qobject_to(QNum, ret); if (!qnum || !qnum_get_try_int(qnum, &retval)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int"); retval = -1; @@ -1136,7 +1136,7 @@ uint64_t object_property_get_uint(struct uc_struct *uc, Object *obj, if (!ret) { return 0; } - qnum = qobject_to_qnum(ret); + qnum = qobject_to(QNum, ret); if (!qnum || !qnum_get_try_uint(qnum, &retval)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint"); retval = 0;