qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi: Replace qobject_to_X(o) by qobject_to(X, o)

This patch was generated using the following Coccinelle script:

@@
expression Obj;
@@
(
- qobject_to_qnum(Obj)
+ qobject_to(QNum, Obj)
|
- qobject_to_qstring(Obj)
+ qobject_to(QString, Obj)
|
- qobject_to_qdict(Obj)
+ qobject_to(QDict, Obj)
|
- qobject_to_qlist(Obj)
+ qobject_to(QList, Obj)
|
- qobject_to_qbool(Obj)
+ qobject_to(QBool, Obj)
)

and a bit of manual fix-up for overly long lines and three places in
tests/check-qjson.c that Coccinelle did not find.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-Id: <20180224154033.29559-4-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: swap order from qobject_to(o, X), rebase to master, also a fix
to latent false-positive compiler complaint about hw/i386/acpi-build.c]
Signed-off-by: Eric Blake <eblake@redhat.com>

authored by

Max Reitz and committed by
Eric Blake
7dc847eb 1a56b1e2

+231 -227
+2 -2
block.c
··· 1457 1457 return NULL; 1458 1458 } 1459 1459 1460 - options = qobject_to_qdict(options_obj); 1460 + options = qobject_to(QDict, options_obj); 1461 1461 if (!options) { 1462 1462 qobject_decref(options_obj); 1463 1463 error_setg(errp, "Invalid JSON object given"); ··· 2433 2433 } 2434 2434 visit_complete(v, &obj); 2435 2435 2436 - qdict = qobject_to_qdict(obj); 2436 + qdict = qobject_to(QDict, obj); 2437 2437 qdict_flatten(qdict); 2438 2438 2439 2439 /* bdrv_open_inherit() defaults to the values in bdrv_flags (for
+1 -1
block/parallels.c
··· 647 647 648 648 qobj = qdict_crumple(qdict, errp); 649 649 QDECREF(qdict); 650 - qdict = qobject_to_qdict(qobj); 650 + qdict = qobject_to(QDict, qobj); 651 651 if (qdict == NULL) { 652 652 ret = -EINVAL; 653 653 goto done;
+6 -6
block/qapi.c
··· 647 647 { 648 648 switch (qobject_type(obj)) { 649 649 case QTYPE_QNUM: { 650 - QNum *value = qobject_to_qnum(obj); 650 + QNum *value = qobject_to(QNum, obj); 651 651 char *tmp = qnum_to_string(value); 652 652 func_fprintf(f, "%s", tmp); 653 653 g_free(tmp); 654 654 break; 655 655 } 656 656 case QTYPE_QSTRING: { 657 - QString *value = qobject_to_qstring(obj); 657 + QString *value = qobject_to(QString, obj); 658 658 func_fprintf(f, "%s", qstring_get_str(value)); 659 659 break; 660 660 } 661 661 case QTYPE_QDICT: { 662 - QDict *value = qobject_to_qdict(obj); 662 + QDict *value = qobject_to(QDict, obj); 663 663 dump_qdict(func_fprintf, f, comp_indent, value); 664 664 break; 665 665 } 666 666 case QTYPE_QLIST: { 667 - QList *value = qobject_to_qlist(obj); 667 + QList *value = qobject_to(QList, obj); 668 668 dump_qlist(func_fprintf, f, comp_indent, value); 669 669 break; 670 670 } 671 671 case QTYPE_QBOOL: { 672 - QBool *value = qobject_to_qbool(obj); 672 + QBool *value = qobject_to(QBool, obj); 673 673 func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"); 674 674 break; 675 675 } ··· 730 730 731 731 visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); 732 732 visit_complete(v, &obj); 733 - data = qdict_get(qobject_to_qdict(obj), "data"); 733 + data = qdict_get(qobject_to(QDict, obj), "data"); 734 734 dump_qobject(func_fprintf, f, 1, data); 735 735 qobject_decref(obj); 736 736 visit_free(v);
+1 -1
block/qcow.c
··· 996 996 997 997 qobj = qdict_crumple(qdict, errp); 998 998 QDECREF(qdict); 999 - qdict = qobject_to_qdict(qobj); 999 + qdict = qobject_to(QDict, qobj); 1000 1000 if (qdict == NULL) { 1001 1001 ret = -EINVAL; 1002 1002 goto fail;
+1 -1
block/qcow2.c
··· 3125 3125 /* Now get the QAPI type BlockdevCreateOptions */ 3126 3126 qobj = qdict_crumple(qdict, errp); 3127 3127 QDECREF(qdict); 3128 - qdict = qobject_to_qdict(qobj); 3128 + qdict = qobject_to(QDict, qobj); 3129 3129 if (qdict == NULL) { 3130 3130 ret = -EINVAL; 3131 3131 goto finish;
+1 -1
block/qed.c
··· 764 764 765 765 qobj = qdict_crumple(qdict, errp); 766 766 QDECREF(qdict); 767 - qdict = qobject_to_qdict(qobj); 767 + qdict = qobject_to(QDict, qobj); 768 768 if (qdict == NULL) { 769 769 ret = -EINVAL; 770 770 goto fail;
+4 -4
block/rbd.c
··· 263 263 if (!keypairs_json) { 264 264 return ret; 265 265 } 266 - keypairs = qobject_to_qlist(qobject_from_json(keypairs_json, 267 - &error_abort)); 266 + keypairs = qobject_to(QList, 267 + qobject_from_json(keypairs_json, &error_abort)); 268 268 remaining = qlist_size(keypairs) / 2; 269 269 assert(remaining); 270 270 271 271 while (remaining--) { 272 - name = qobject_to_qstring(qlist_pop(keypairs)); 273 - value = qobject_to_qstring(qlist_pop(keypairs)); 272 + name = qobject_to(QString, qlist_pop(keypairs)); 273 + value = qobject_to(QString, qlist_pop(keypairs)); 274 274 assert(name && value); 275 275 key = qstring_get_str(name); 276 276
+1 -1
block/sheepdog.c
··· 1887 1887 return -EINVAL; 1888 1888 } 1889 1889 1890 - qdict = qobject_to_qdict(obj); 1890 + qdict = qobject_to(QDict, obj); 1891 1891 qdict_flatten(qdict); 1892 1892 1893 1893 qdict_put_str(qdict, "driver", "sheepdog");
+1 -1
block/vhdx.c
··· 1997 1997 1998 1998 qobj = qdict_crumple(qdict, errp); 1999 1999 QDECREF(qdict); 2000 - qdict = qobject_to_qdict(qobj); 2000 + qdict = qobject_to(QDict, qobj); 2001 2001 if (qdict == NULL) { 2002 2002 ret = -EINVAL; 2003 2003 goto fail;
+1 -1
block/vpc.c
··· 1120 1120 1121 1121 qobj = qdict_crumple(qdict, errp); 1122 1122 QDECREF(qdict); 1123 - qdict = qobject_to_qdict(qobj); 1123 + qdict = qobject_to(QDict, qobj); 1124 1124 if (qdict == NULL) { 1125 1125 ret = -EINVAL; 1126 1126 goto fail;
+4 -3
blockdev.c
··· 334 334 335 335 case QTYPE_QSTRING: { 336 336 unsigned long long length; 337 - const char *str = qstring_get_str(qobject_to_qstring(entry->value)); 337 + const char *str = qstring_get_str(qobject_to(QString, 338 + entry->value)); 338 339 if (parse_uint_full(str, &length, 10) == 0 && 339 340 length > 0 && length <= UINT_MAX) { 340 341 block_acct_add_interval(stats, (unsigned) length); ··· 346 347 } 347 348 348 349 case QTYPE_QNUM: { 349 - int64_t length = qnum_get_int(qobject_to_qnum(entry->value)); 350 + int64_t length = qnum_get_int(qobject_to(QNum, entry->value)); 350 351 351 352 if (length > 0 && length <= UINT_MAX) { 352 353 block_acct_add_interval(stats, (unsigned) length); ··· 4054 4055 } 4055 4056 4056 4057 visit_complete(v, &obj); 4057 - qdict = qobject_to_qdict(obj); 4058 + qdict = qobject_to(QDict, obj); 4058 4059 4059 4060 qdict_flatten(qdict); 4060 4061
+8 -8
hw/i386/acpi-build.c
··· 154 154 /* Fill in optional s3/s4 related properties */ 155 155 o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL); 156 156 if (o) { 157 - pm->s3_disabled = qnum_get_uint(qobject_to_qnum(o)); 157 + pm->s3_disabled = qnum_get_uint(qobject_to(QNum, o)); 158 158 } else { 159 159 pm->s3_disabled = false; 160 160 } 161 161 qobject_decref(o); 162 162 o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL); 163 163 if (o) { 164 - pm->s4_disabled = qnum_get_uint(qobject_to_qnum(o)); 164 + pm->s4_disabled = qnum_get_uint(qobject_to(QNum, o)); 165 165 } else { 166 166 pm->s4_disabled = false; 167 167 } 168 168 qobject_decref(o); 169 169 o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL); 170 170 if (o) { 171 - pm->s4_val = qnum_get_uint(qobject_to_qnum(o)); 171 + pm->s4_val = qnum_get_uint(qobject_to(QNum, o)); 172 172 } else { 173 173 pm->s4_val = false; 174 174 } ··· 507 507 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, 508 508 bool pcihp_bridge_en) 509 509 { 510 - Aml *dev, *notify_method, *method; 510 + Aml *dev, *notify_method = NULL, *method; 511 511 QObject *bsel; 512 512 PCIBus *sec; 513 513 int i; 514 514 515 515 bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL); 516 516 if (bsel) { 517 - uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel)); 517 + uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel)); 518 518 519 519 aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val))); 520 520 notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED); ··· 624 624 625 625 /* If bus supports hotplug select it and notify about local events */ 626 626 if (bsel) { 627 - uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel)); 627 + uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel)); 628 628 629 629 aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM"))); 630 630 aml_append(method, ··· 2638 2638 if (!o) { 2639 2639 return false; 2640 2640 } 2641 - mcfg->mcfg_base = qnum_get_uint(qobject_to_qnum(o)); 2641 + mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o)); 2642 2642 qobject_decref(o); 2643 2643 2644 2644 o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL); 2645 2645 assert(o); 2646 - mcfg->mcfg_size = qnum_get_uint(qobject_to_qnum(o)); 2646 + mcfg->mcfg_size = qnum_get_uint(qobject_to(QNum, o)); 2647 2647 qobject_decref(o); 2648 2648 return true; 2649 2649 }
+4 -4
monitor.c
··· 447 447 /* Unthrottled event */ 448 448 monitor_qapi_event_emit(event, qdict); 449 449 } else { 450 - QDict *data = qobject_to_qdict(qdict_get(qdict, "data")); 450 + QDict *data = qobject_to(QDict, qdict_get(qdict, "data")); 451 451 MonitorQAPIEventState key = { .event = event, .data = data }; 452 452 453 453 evstate = g_hash_table_lookup(monitor_qapi_event_state, &key); ··· 3777 3777 goto err_out; 3778 3778 } 3779 3779 3780 - qdict = qobject_to_qdict(req); 3780 + qdict = qobject_to(QDict, req); 3781 3781 if (qdict) { 3782 3782 id = qdict_get(qdict, "id"); 3783 3783 qobject_incref(id); ··· 3793 3793 rsp = qmp_dispatch(cur_mon->qmp.commands, req); 3794 3794 3795 3795 if (mon->qmp.commands == &qmp_cap_negotiation_commands) { 3796 - qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error"); 3796 + qdict = qdict_get_qdict(qobject_to(QDict, rsp), "error"); 3797 3797 if (qdict 3798 3798 && !g_strcmp0(qdict_get_try_str(qdict, "class"), 3799 3799 QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) { ··· 3814 3814 3815 3815 if (rsp) { 3816 3816 if (id) { 3817 - qdict_put_obj(qobject_to_qdict(rsp), "id", id); 3817 + qdict_put_obj(qobject_to(QDict, rsp), "id", id); 3818 3818 id = NULL; 3819 3819 } 3820 3820
+1 -1
qapi/qmp-dispatch.c
··· 26 26 bool has_exec_key = false; 27 27 QDict *dict = NULL; 28 28 29 - dict = qobject_to_qdict(request); 29 + dict = qobject_to(QDict, request); 30 30 if (!dict) { 31 31 error_setg(errp, "QMP input must be a JSON object"); 32 32 return NULL;
+10 -10
qapi/qobject-input-visitor.c
··· 137 137 138 138 if (qobject_type(qobj) == QTYPE_QDICT) { 139 139 assert(name); 140 - ret = qdict_get(qobject_to_qdict(qobj), name); 140 + ret = qdict_get(qobject_to(QDict, qobj), name); 141 141 if (tos->h && consume && ret) { 142 142 bool removed = g_hash_table_remove(tos->h, name); 143 143 assert(removed); ··· 185 185 return NULL; 186 186 } 187 187 188 - qstr = qobject_to_qstring(qobj); 188 + qstr = qobject_to(QString, qobj); 189 189 if (!qstr) { 190 190 switch (qobject_type(qobj)) { 191 191 case QTYPE_QDICT: ··· 224 224 225 225 if (qobject_type(obj) == QTYPE_QDICT) { 226 226 h = g_hash_table_new(g_str_hash, g_str_equal); 227 - qdict_iter(qobject_to_qdict(obj), qdict_add_key, h); 227 + qdict_iter(qobject_to(QDict, obj), qdict_add_key, h); 228 228 tos->h = h; 229 229 } else { 230 230 assert(qobject_type(obj) == QTYPE_QLIST); 231 - tos->entry = qlist_first(qobject_to_qlist(obj)); 231 + tos->entry = qlist_first(qobject_to(QList, obj)); 232 232 tos->index = -1; 233 233 } 234 234 ··· 395 395 if (!qobj) { 396 396 return; 397 397 } 398 - qnum = qobject_to_qnum(qobj); 398 + qnum = qobject_to(QNum, qobj); 399 399 if (!qnum || !qnum_get_try_int(qnum, obj)) { 400 400 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, 401 401 full_name(qiv, name), "integer"); ··· 430 430 if (!qobj) { 431 431 return; 432 432 } 433 - qnum = qobject_to_qnum(qobj); 433 + qnum = qobject_to(QNum, qobj); 434 434 if (!qnum) { 435 435 goto err; 436 436 } ··· 477 477 if (!qobj) { 478 478 return; 479 479 } 480 - qbool = qobject_to_qbool(qobj); 480 + qbool = qobject_to(QBool, qobj); 481 481 if (!qbool) { 482 482 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, 483 483 full_name(qiv, name), "boolean"); ··· 518 518 if (!qobj) { 519 519 return; 520 520 } 521 - qstr = qobject_to_qstring(qobj); 521 + qstr = qobject_to(QString, qobj); 522 522 if (!qstr) { 523 523 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, 524 524 full_name(qiv, name), "string"); ··· 547 547 if (!qobj) { 548 548 return; 549 549 } 550 - qnum = qobject_to_qnum(qobj); 550 + qnum = qobject_to(QNum, qobj); 551 551 if (!qnum) { 552 552 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, 553 553 full_name(qiv, name), "number"); ··· 734 734 } 735 735 return NULL; 736 736 } 737 - args = qobject_to_qdict(obj); 737 + args = qobject_to(QDict, obj); 738 738 assert(args); 739 739 v = qobject_input_visitor_new(QOBJECT(args)); 740 740 } else {
+2 -2
qapi/qobject-output-visitor.c
··· 92 92 switch (qobject_type(cur)) { 93 93 case QTYPE_QDICT: 94 94 assert(name); 95 - qdict_put_obj(qobject_to_qdict(cur), name, value); 95 + qdict_put_obj(qobject_to(QDict, cur), name, value); 96 96 break; 97 97 case QTYPE_QLIST: 98 98 assert(!name); 99 - qlist_append_obj(qobject_to_qlist(cur), value); 99 + qlist_append_obj(qobject_to(QList, cur), value); 100 100 break; 101 101 default: 102 102 g_assert_not_reached();
+1 -1
qga/main.c
··· 607 607 g_assert(s && parser); 608 608 609 609 g_debug("process_event: called"); 610 - qdict = qobject_to_qdict(json_parser_parse_err(tokens, NULL, &err)); 610 + qdict = qobject_to(QDict, json_parser_parse_err(tokens, NULL, &err)); 611 611 if (err || !qdict) { 612 612 QDECREF(qdict); 613 613 qdict = qdict_new();
+1 -1
qmp.c
··· 705 705 Object *obj; 706 706 707 707 if (props) { 708 - pdict = qobject_to_qdict(props); 708 + pdict = qobject_to(QDict, props); 709 709 if (!pdict) { 710 710 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); 711 711 return;
+1 -1
qobject/json-parser.c
··· 308 308 goto out; 309 309 } 310 310 311 - qdict_put_obj(dict, qstring_get_str(qobject_to_qstring(key)), value); 311 + qdict_put_obj(dict, qstring_get_str(qobject_to(QString, key)), value); 312 312 313 313 qobject_decref(key); 314 314
+2 -2
qobject/qbool.c
··· 55 55 */ 56 56 bool qbool_is_equal(const QObject *x, const QObject *y) 57 57 { 58 - return qobject_to_qbool(x)->value == qobject_to_qbool(y)->value; 58 + return qobject_to(QBool, x)->value == qobject_to(QBool, y)->value; 59 59 } 60 60 61 61 /** ··· 65 65 void qbool_destroy_obj(QObject *obj) 66 66 { 67 67 assert(obj != NULL); 68 - g_free(qobject_to_qbool(obj)); 68 + g_free(qobject_to(QBool, obj)); 69 69 }
+19 -19
qobject/qdict.c
··· 206 206 */ 207 207 double qdict_get_double(const QDict *qdict, const char *key) 208 208 { 209 - return qnum_get_double(qobject_to_qnum(qdict_get(qdict, key))); 209 + return qnum_get_double(qobject_to(QNum, qdict_get(qdict, key))); 210 210 } 211 211 212 212 /** ··· 219 219 */ 220 220 int64_t qdict_get_int(const QDict *qdict, const char *key) 221 221 { 222 - return qnum_get_int(qobject_to_qnum(qdict_get(qdict, key))); 222 + return qnum_get_int(qobject_to(QNum, qdict_get(qdict, key))); 223 223 } 224 224 225 225 /** ··· 232 232 */ 233 233 bool qdict_get_bool(const QDict *qdict, const char *key) 234 234 { 235 - return qbool_get_bool(qobject_to_qbool(qdict_get(qdict, key))); 235 + return qbool_get_bool(qobject_to(QBool, qdict_get(qdict, key))); 236 236 } 237 237 238 238 /** ··· 240 240 */ 241 241 QList *qdict_get_qlist(const QDict *qdict, const char *key) 242 242 { 243 - return qobject_to_qlist(qdict_get(qdict, key)); 243 + return qobject_to(QList, qdict_get(qdict, key)); 244 244 } 245 245 246 246 /** ··· 248 248 */ 249 249 QDict *qdict_get_qdict(const QDict *qdict, const char *key) 250 250 { 251 - return qobject_to_qdict(qdict_get(qdict, key)); 251 + return qobject_to(QDict, qdict_get(qdict, key)); 252 252 } 253 253 254 254 /** ··· 262 262 */ 263 263 const char *qdict_get_str(const QDict *qdict, const char *key) 264 264 { 265 - return qstring_get_str(qobject_to_qstring(qdict_get(qdict, key))); 265 + return qstring_get_str(qobject_to(QString, qdict_get(qdict, key))); 266 266 } 267 267 268 268 /** ··· 275 275 int64_t qdict_get_try_int(const QDict *qdict, const char *key, 276 276 int64_t def_value) 277 277 { 278 - QNum *qnum = qobject_to_qnum(qdict_get(qdict, key)); 278 + QNum *qnum = qobject_to(QNum, qdict_get(qdict, key)); 279 279 int64_t val; 280 280 281 281 if (!qnum || !qnum_get_try_int(qnum, &val)) { ··· 294 294 */ 295 295 bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value) 296 296 { 297 - QBool *qbool = qobject_to_qbool(qdict_get(qdict, key)); 297 + QBool *qbool = qobject_to(QBool, qdict_get(qdict, key)); 298 298 299 299 return qbool ? qbool_get_bool(qbool) : def_value; 300 300 } ··· 309 309 */ 310 310 const char *qdict_get_try_str(const QDict *qdict, const char *key) 311 311 { 312 - QString *qstr = qobject_to_qstring(qdict_get(qdict, key)); 312 + QString *qstr = qobject_to(QString, qdict_get(qdict, key)); 313 313 314 314 return qstr ? qstring_get_str(qstr) : NULL; 315 315 } ··· 432 432 */ 433 433 bool qdict_is_equal(const QObject *x, const QObject *y) 434 434 { 435 - const QDict *dict_x = qobject_to_qdict(x); 436 - const QDict *dict_y = qobject_to_qdict(y); 435 + const QDict *dict_x = qobject_to(QDict, x); 436 + const QDict *dict_y = qobject_to(QDict, y); 437 437 const QDictEntry *e; 438 438 439 439 if (qdict_size(dict_x) != qdict_size(dict_y)) { ··· 461 461 QDict *qdict; 462 462 463 463 assert(obj != NULL); 464 - qdict = qobject_to_qdict(obj); 464 + qdict = qobject_to(QDict, obj); 465 465 466 466 for (i = 0; i < QDICT_BUCKET_MAX; i++) { 467 467 QDictEntry *entry = QLIST_FIRST(&qdict->table[i]); ··· 532 532 new_key = g_strdup_printf("%s.%i", prefix, i); 533 533 534 534 if (qobject_type(value) == QTYPE_QDICT) { 535 - qdict_flatten_qdict(qobject_to_qdict(value), target, new_key); 535 + qdict_flatten_qdict(qobject_to(QDict, value), target, new_key); 536 536 } else if (qobject_type(value) == QTYPE_QLIST) { 537 - qdict_flatten_qlist(qobject_to_qlist(value), target, new_key); 537 + qdict_flatten_qlist(qobject_to(QList, value), target, new_key); 538 538 } else { 539 539 /* All other types are moved to the target unchanged. */ 540 540 qobject_incref(value); ··· 568 568 if (qobject_type(value) == QTYPE_QDICT) { 569 569 /* Entries of QDicts are processed recursively, the QDict object 570 570 * itself disappears. */ 571 - qdict_flatten_qdict(qobject_to_qdict(value), target, 571 + qdict_flatten_qdict(qobject_to(QDict, value), target, 572 572 new_key ? new_key : entry->key); 573 573 delete = true; 574 574 } else if (qobject_type(value) == QTYPE_QLIST) { 575 - qdict_flatten_qlist(qobject_to_qlist(value), target, 575 + qdict_flatten_qlist(qobject_to(QList, value), target, 576 576 new_key ? new_key : entry->key); 577 577 delete = true; 578 578 } else if (prefix) { ··· 904 904 qdict_put_obj(two_level, prefix, child); 905 905 } 906 906 qobject_incref(ent->value); 907 - qdict_put_obj(qobject_to_qdict(child), suffix, ent->value); 907 + qdict_put_obj(qobject_to(QDict, child), suffix, ent->value); 908 908 } else { 909 909 if (child) { 910 910 error_setg(errp, "Key %s prefix is already set as a dict", ··· 926 926 ent = qdict_next(two_level, ent)) { 927 927 928 928 if (qobject_type(ent->value) == QTYPE_QDICT) { 929 - child = qdict_crumple(qobject_to_qdict(ent->value), errp); 929 + child = qdict_crumple(qobject_to(QDict, ent->value), errp); 930 930 if (!child) { 931 931 goto error; 932 932 } ··· 961 961 } 962 962 963 963 qobject_incref(child); 964 - qlist_append_obj(qobject_to_qlist(dst), child); 964 + qlist_append_obj(qobject_to(QList, dst), child); 965 965 } 966 966 QDECREF(multi_level); 967 967 multi_level = NULL;
+5 -5
qobject/qjson.c
··· 137 137 qstring_append(str, "null"); 138 138 break; 139 139 case QTYPE_QNUM: { 140 - QNum *val = qobject_to_qnum(obj); 140 + QNum *val = qobject_to(QNum, obj); 141 141 char *buffer = qnum_to_string(val); 142 142 qstring_append(str, buffer); 143 143 g_free(buffer); 144 144 break; 145 145 } 146 146 case QTYPE_QSTRING: { 147 - QString *val = qobject_to_qstring(obj); 147 + QString *val = qobject_to(QString, obj); 148 148 const char *ptr; 149 149 int cp; 150 150 char buf[16]; ··· 201 201 } 202 202 case QTYPE_QDICT: { 203 203 ToJsonIterState s; 204 - QDict *val = qobject_to_qdict(obj); 204 + QDict *val = qobject_to(QDict, obj); 205 205 206 206 s.count = 0; 207 207 s.str = str; ··· 220 220 } 221 221 case QTYPE_QLIST: { 222 222 ToJsonIterState s; 223 - QList *val = qobject_to_qlist(obj); 223 + QList *val = qobject_to(QList, obj); 224 224 225 225 s.count = 0; 226 226 s.str = str; ··· 238 238 break; 239 239 } 240 240 case QTYPE_QBOOL: { 241 - QBool *val = qobject_to_qbool(obj); 241 + QBool *val = qobject_to(QBool, obj); 242 242 243 243 if (qbool_get_bool(val)) { 244 244 qstring_append(str, "true");
+3 -3
qobject/qlist.c
··· 173 173 */ 174 174 bool qlist_is_equal(const QObject *x, const QObject *y) 175 175 { 176 - const QList *list_x = qobject_to_qlist(x); 177 - const QList *list_y = qobject_to_qlist(y); 176 + const QList *list_x = qobject_to(QList, x); 177 + const QList *list_y = qobject_to(QList, y); 178 178 const QListEntry *entry_x, *entry_y; 179 179 180 180 entry_x = qlist_first(list_x); ··· 203 203 QListEntry *entry, *next_entry; 204 204 205 205 assert(obj != NULL); 206 - qlist = qobject_to_qlist(obj); 206 + qlist = qobject_to(QList, obj); 207 207 208 208 QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) { 209 209 QTAILQ_REMOVE(&qlist->head, entry, next);
+5 -5
qobject/qlit.c
··· 69 69 70 70 switch (lhs->type) { 71 71 case QTYPE_QBOOL: 72 - return lhs->value.qbool == qbool_get_bool(qobject_to_qbool(rhs)); 72 + return lhs->value.qbool == qbool_get_bool(qobject_to(QBool, rhs)); 73 73 case QTYPE_QNUM: 74 - return lhs->value.qnum == qnum_get_int(qobject_to_qnum(rhs)); 74 + return lhs->value.qnum == qnum_get_int(qobject_to(QNum, rhs)); 75 75 case QTYPE_QSTRING: 76 76 return (strcmp(lhs->value.qstr, 77 - qstring_get_str(qobject_to_qstring(rhs))) == 0); 77 + qstring_get_str(qobject_to(QString, rhs))) == 0); 78 78 case QTYPE_QDICT: 79 - return qlit_equal_qdict(lhs, qobject_to_qdict(rhs)); 79 + return qlit_equal_qdict(lhs, qobject_to(QDict, rhs)); 80 80 case QTYPE_QLIST: 81 - return qlit_equal_qlist(lhs, qobject_to_qlist(rhs)); 81 + return qlit_equal_qlist(lhs, qobject_to(QList, rhs)); 82 82 case QTYPE_QNULL: 83 83 return true; 84 84 default:
+3 -3
qobject/qnum.c
··· 221 221 */ 222 222 bool qnum_is_equal(const QObject *x, const QObject *y) 223 223 { 224 - QNum *num_x = qobject_to_qnum(x); 225 - QNum *num_y = qobject_to_qnum(y); 224 + QNum *num_x = qobject_to(QNum, x); 225 + QNum *num_y = qobject_to(QNum, y); 226 226 227 227 switch (num_x->kind) { 228 228 case QNUM_I64: ··· 271 271 void qnum_destroy_obj(QObject *obj) 272 272 { 273 273 assert(obj != NULL); 274 - g_free(qobject_to_qnum(obj)); 274 + g_free(qobject_to(QNum, obj)); 275 275 }
+3 -3
qobject/qstring.c
··· 132 132 */ 133 133 bool qstring_is_equal(const QObject *x, const QObject *y) 134 134 { 135 - return !strcmp(qobject_to_qstring(x)->string, 136 - qobject_to_qstring(y)->string); 135 + return !strcmp(qobject_to(QString, x)->string, 136 + qobject_to(QString, y)->string); 137 137 } 138 138 139 139 /** ··· 145 145 QString *qs; 146 146 147 147 assert(obj != NULL); 148 - qs = qobject_to_qstring(obj); 148 + qs = qobject_to(QString, obj); 149 149 g_free(qs->string); 150 150 g_free(qs); 151 151 }
+4 -4
qom/object.c
··· 1142 1142 if (!ret) { 1143 1143 return NULL; 1144 1144 } 1145 - qstring = qobject_to_qstring(ret); 1145 + qstring = qobject_to(QString, ret); 1146 1146 if (!qstring) { 1147 1147 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string"); 1148 1148 retval = NULL; ··· 1203 1203 if (!ret) { 1204 1204 return false; 1205 1205 } 1206 - qbool = qobject_to_qbool(ret); 1206 + qbool = qobject_to(QBool, ret); 1207 1207 if (!qbool) { 1208 1208 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); 1209 1209 retval = false; ··· 1235 1235 return -1; 1236 1236 } 1237 1237 1238 - qnum = qobject_to_qnum(ret); 1238 + qnum = qobject_to(QNum, ret); 1239 1239 if (!qnum || !qnum_get_try_int(qnum, &retval)) { 1240 1240 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int"); 1241 1241 retval = -1; ··· 1264 1264 if (!ret) { 1265 1265 return 0; 1266 1266 } 1267 - qnum = qobject_to_qnum(ret); 1267 + qnum = qobject_to(QNum, ret); 1268 1268 if (!qnum || !qnum_get_try_uint(qnum, &retval)) { 1269 1269 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint"); 1270 1270 retval = 0;
+1 -1
target/i386/cpu.c
··· 3141 3141 3142 3142 xc = x86_cpu_from_model(model->name, 3143 3143 model->has_props ? 3144 - qobject_to_qdict(model->props) : 3144 + qobject_to(QDict, model->props) : 3145 3145 NULL, &err); 3146 3146 if (err) { 3147 3147 goto out;
+1 -1
target/s390x/cpu_models.c
··· 453 453 Object *obj; 454 454 455 455 if (info->props) { 456 - qdict = qobject_to_qdict(info->props); 456 + qdict = qobject_to(QDict, info->props); 457 457 if (!qdict) { 458 458 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); 459 459 return;
+10 -10
tests/check-qdict.c
··· 51 51 52 52 g_assert(qdict_size(qdict) == 1); 53 53 ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); 54 - qn = qobject_to_qnum(ent->value); 54 + qn = qobject_to(QNum, ent->value); 55 55 g_assert_cmpint(qnum_get_int(qn), ==, num); 56 56 57 57 QDECREF(qdict); ··· 81 81 obj = qdict_get(tests_dict, key); 82 82 g_assert(obj != NULL); 83 83 84 - qn = qobject_to_qnum(obj); 84 + qn = qobject_to(QNum, obj); 85 85 g_assert_cmpint(qnum_get_int(qn), ==, value); 86 86 87 87 QDECREF(tests_dict); ··· 216 216 static void qobject_to_qdict_test(void) 217 217 { 218 218 QDict *tests_dict = qdict_new(); 219 - g_assert(qobject_to_qdict(QOBJECT(tests_dict)) == tests_dict); 219 + g_assert(qobject_to(QDict, QOBJECT(tests_dict)) == tests_dict); 220 220 221 221 QDECREF(tests_dict); 222 222 } ··· 381 381 382 382 qdict_array_split(test_dict, &test_list); 383 383 384 - dict1 = qobject_to_qdict(qlist_pop(test_list)); 385 - dict2 = qobject_to_qdict(qlist_pop(test_list)); 386 - int1 = qobject_to_qnum(qlist_pop(test_list)); 384 + dict1 = qobject_to(QDict, qlist_pop(test_list)); 385 + dict2 = qobject_to(QDict, qlist_pop(test_list)); 386 + int1 = qobject_to(QNum, qlist_pop(test_list)); 387 387 388 388 g_assert(dict1); 389 389 g_assert(dict2); ··· 450 450 451 451 qdict_array_split(test_dict, &test_list); 452 452 453 - int1 = qobject_to_qnum(qlist_pop(test_list)); 453 + int1 = qobject_to(QNum, qlist_pop(test_list)); 454 454 455 455 g_assert(int1); 456 456 g_assert(qlist_empty(test_list)); ··· 607 607 qdict_put_str(src, "vnc.acl..name", "acl0"); 608 608 qdict_put_str(src, "vnc.acl.rule..name", "acl0"); 609 609 610 - dst = qobject_to_qdict(qdict_crumple(src, &error_abort)); 610 + dst = qobject_to(QDict, qdict_crumple(src, &error_abort)); 611 611 g_assert(dst); 612 612 g_assert_cmpint(qdict_size(dst), ==, 1); 613 613 ··· 629 629 g_assert(rules); 630 630 g_assert_cmpint(qlist_size(rules), ==, 2); 631 631 632 - rule = qobject_to_qdict(qlist_pop(rules)); 632 + rule = qobject_to(QDict, qlist_pop(rules)); 633 633 g_assert(rule); 634 634 g_assert_cmpint(qdict_size(rule), ==, 2); 635 635 g_assert_cmpstr("fred", ==, qdict_get_str(rule, "match")); 636 636 g_assert_cmpstr("allow", ==, qdict_get_str(rule, "policy")); 637 637 QDECREF(rule); 638 638 639 - rule = qobject_to_qdict(qlist_pop(rules)); 639 + rule = qobject_to(QDict, qlist_pop(rules)); 640 640 g_assert(rule); 641 641 g_assert_cmpint(qdict_size(rule), ==, 2); 642 642 g_assert_cmpstr("bob", ==, qdict_get_str(rule, "match"));
+21 -20
tests/check-qjson.c
··· 60 60 QString *str; 61 61 62 62 obj = qobject_from_json(test_cases[i].encoded, &error_abort); 63 - str = qobject_to_qstring(obj); 63 + str = qobject_to(QString, obj); 64 64 g_assert(str); 65 65 g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded); 66 66 ··· 92 92 QString *str; 93 93 94 94 obj = qobject_from_json(test_cases[i].encoded, &error_abort); 95 - str = qobject_to_qstring(obj); 95 + str = qobject_to(QString, obj); 96 96 g_assert(str); 97 97 g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); 98 98 ··· 123 123 QString *str; 124 124 125 125 obj = qobject_from_json(test_cases[i].encoded, &error_abort); 126 - str = qobject_to_qstring(obj); 126 + str = qobject_to(QString, obj); 127 127 g_assert(str); 128 128 g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); 129 129 ··· 817 817 818 818 obj = qobject_from_json(json_in, utf8_out ? &error_abort : NULL); 819 819 if (utf8_out) { 820 - str = qobject_to_qstring(obj); 820 + str = qobject_to(QString, obj); 821 821 g_assert(str); 822 822 g_assert_cmpstr(qstring_get_str(str), ==, utf8_out); 823 823 } else { ··· 843 843 */ 844 844 if (0 && json_out != json_in) { 845 845 obj = qobject_from_json(json_out, &error_abort); 846 - str = qobject_to_qstring(obj); 846 + str = qobject_to(QString, obj); 847 847 g_assert(str); 848 848 g_assert_cmpstr(qstring_get_str(str), ==, utf8_out); 849 849 } ··· 864 864 for (i = 0; test_cases[i].decoded; i++) { 865 865 QString *str; 866 866 867 - str = qobject_to_qstring(qobject_from_jsonf("%s", 868 - test_cases[i].decoded)); 867 + str = qobject_to(QString, 868 + qobject_from_jsonf("%s", test_cases[i].decoded)); 869 869 g_assert(str); 870 870 g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); 871 871 ··· 893 893 QNum *qnum; 894 894 int64_t val; 895 895 896 - qnum = qobject_to_qnum(qobject_from_json(test_cases[i].encoded, 897 - &error_abort)); 896 + qnum = qobject_to(QNum, 897 + qobject_from_json(test_cases[i].encoded, 898 + &error_abort)); 898 899 g_assert(qnum); 899 900 g_assert(qnum_get_try_int(qnum, &val)); 900 901 g_assert_cmpint(val, ==, test_cases[i].decoded); ··· 920 921 uint64_t val; 921 922 int64_t ival; 922 923 923 - qnum = qobject_to_qnum(qobject_from_json(maxu64, &error_abort)); 924 + qnum = qobject_to(QNum, qobject_from_json(maxu64, &error_abort)); 924 925 g_assert(qnum); 925 926 g_assert_cmpuint(qnum_get_uint(qnum), ==, 18446744073709551615U); 926 927 g_assert(!qnum_get_try_int(qnum, &ival)); ··· 930 931 QDECREF(str); 931 932 QDECREF(qnum); 932 933 933 - qnum = qobject_to_qnum(qobject_from_json(gtu64, &error_abort)); 934 + qnum = qobject_to(QNum, qobject_from_json(gtu64, &error_abort)); 934 935 g_assert(qnum); 935 936 g_assert_cmpfloat(qnum_get_double(qnum), ==, 18446744073709552e3); 936 937 g_assert(!qnum_get_try_uint(qnum, &val)); ··· 941 942 QDECREF(str); 942 943 QDECREF(qnum); 943 944 944 - qnum = qobject_to_qnum(qobject_from_json(lti64, &error_abort)); 945 + qnum = qobject_to(QNum, qobject_from_json(lti64, &error_abort)); 945 946 g_assert(qnum); 946 947 g_assert_cmpfloat(qnum_get_double(qnum), ==, -92233720368547758e2); 947 948 g_assert(!qnum_get_try_uint(qnum, &val)); ··· 973 974 QNum *qnum; 974 975 975 976 obj = qobject_from_json(test_cases[i].encoded, &error_abort); 976 - qnum = qobject_to_qnum(obj); 977 + qnum = qobject_to(QNum, obj); 977 978 g_assert(qnum); 978 979 g_assert(qnum_get_double(qnum) == test_cases[i].decoded); 979 980 ··· 997 998 double valuef = 2.323423423; 998 999 int64_t val; 999 1000 1000 - qnum = qobject_to_qnum(qobject_from_jsonf("%d", value)); 1001 + qnum = qobject_to(QNum, qobject_from_jsonf("%d", value)); 1001 1002 g_assert(qnum_get_try_int(qnum, &val)); 1002 1003 g_assert_cmpint(val, ==, value); 1003 1004 QDECREF(qnum); 1004 1005 1005 - qnum = qobject_to_qnum(qobject_from_jsonf("%lld", value_ll)); 1006 + qnum = qobject_to(QNum, qobject_from_jsonf("%lld", value_ll)); 1006 1007 g_assert(qnum_get_try_int(qnum, &val)); 1007 1008 g_assert_cmpint(val, ==, value_ll); 1008 1009 QDECREF(qnum); 1009 1010 1010 - qnum = qobject_to_qnum(qobject_from_jsonf("%f", valuef)); 1011 + qnum = qobject_to(QNum, qobject_from_jsonf("%f", valuef)); 1011 1012 g_assert(qnum_get_double(qnum) == valuef); 1012 1013 QDECREF(qnum); 1013 1014 } ··· 1020 1021 QString *str; 1021 1022 1022 1023 obj = qobject_from_json("true", &error_abort); 1023 - qbool = qobject_to_qbool(obj); 1024 + qbool = qobject_to(QBool, obj); 1024 1025 g_assert(qbool); 1025 1026 g_assert(qbool_get_bool(qbool) == true); 1026 1027 ··· 1031 1032 QDECREF(qbool); 1032 1033 1033 1034 obj = qobject_from_json("false", &error_abort); 1034 - qbool = qobject_to_qbool(obj); 1035 + qbool = qobject_to(QBool, obj); 1035 1036 g_assert(qbool); 1036 1037 g_assert(qbool_get_bool(qbool) == false); 1037 1038 ··· 1041 1042 1042 1043 QDECREF(qbool); 1043 1044 1044 - qbool = qobject_to_qbool(qobject_from_jsonf("%i", false)); 1045 + qbool = qobject_to(QBool, qobject_from_jsonf("%i", false)); 1045 1046 g_assert(qbool); 1046 1047 g_assert(qbool_get_bool(qbool) == false); 1047 1048 QDECREF(qbool); 1048 1049 1049 1050 /* Test that non-zero values other than 1 get collapsed to true */ 1050 - qbool = qobject_to_qbool(qobject_from_jsonf("%i", 2)); 1051 + qbool = qobject_to(QBool, qobject_from_jsonf("%i", 2)); 1051 1052 g_assert(qbool); 1052 1053 g_assert(qbool_get_bool(qbool) == true); 1053 1054 QDECREF(qbool);
+2 -2
tests/check-qlist.c
··· 56 56 57 57 qlist = qlist_new(); 58 58 59 - g_assert(qobject_to_qlist(QOBJECT(qlist)) == qlist); 59 + g_assert(qobject_to(QList, QOBJECT(qlist)) == qlist); 60 60 61 61 QDECREF(qlist); 62 62 } ··· 71 71 72 72 g_assert(opaque == NULL); 73 73 74 - qi = qobject_to_qnum(obj); 74 + qi = qobject_to(QNum, obj); 75 75 g_assert(qi != NULL); 76 76 77 77 g_assert(qnum_get_try_int(qi, &val));
+5 -5
tests/check-qlit.c
··· 59 59 60 60 g_assert(!qlit_equal_qobject(&qlit_foo, qobj)); 61 61 62 - qdict_put(qobject_to_qdict(qobj), "bee", qlist_new()); 62 + qdict_put(qobject_to(QDict, qobj), "bee", qlist_new()); 63 63 g_assert(!qlit_equal_qobject(&qlit, qobj)); 64 64 65 65 qobject_decref(qobj); ··· 71 71 QDict *qdict; 72 72 QList *bee; 73 73 74 - qdict = qobject_to_qdict(qobj); 74 + qdict = qobject_to(QDict, qobj); 75 75 g_assert_cmpint(qdict_get_int(qdict, "foo"), ==, 42); 76 76 g_assert_cmpstr(qdict_get_str(qdict, "bar"), ==, "hello world"); 77 77 g_assert(qobject_type(qdict_get(qdict, "baz")) == QTYPE_QNULL); 78 78 79 79 bee = qdict_get_qlist(qdict, "bee"); 80 80 obj = qlist_pop(bee); 81 - g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), ==, 43); 81 + g_assert_cmpint(qnum_get_int(qobject_to(QNum, obj)), ==, 43); 82 82 qobject_decref(obj); 83 83 obj = qlist_pop(bee); 84 - g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), ==, 44); 84 + g_assert_cmpint(qnum_get_int(qobject_to(QNum, obj)), ==, 44); 85 85 qobject_decref(obj); 86 86 obj = qlist_pop(bee); 87 - g_assert(qbool_get_bool(qobject_to_qbool(obj))); 87 + g_assert(qbool_get_bool(qobject_to(QBool, obj))); 88 88 qobject_decref(obj); 89 89 90 90 qobject_decref(qobj);
+2 -2
tests/check-qnum.c
··· 126 126 QNum *qn; 127 127 128 128 qn = qnum_from_int(0); 129 - g_assert(qobject_to_qnum(QOBJECT(qn)) == qn); 129 + g_assert(qobject_to(QNum, QOBJECT(qn)) == qn); 130 130 QDECREF(qn); 131 131 132 132 qn = qnum_from_double(0); 133 - g_assert(qobject_to_qnum(QOBJECT(qn)) == qn); 133 + g_assert(qobject_to(QNum, QOBJECT(qn)) == qn); 134 134 QDECREF(qn); 135 135 } 136 136
+1 -1
tests/check-qobject.c
··· 275 275 dict_different_null_key, dict_longer, dict_shorter, 276 276 dict_nested); 277 277 278 - dict_crumpled = qobject_to_qdict(qdict_crumple(dict_1, &local_err)); 278 + dict_crumpled = qobject_to(QDict, qdict_crumple(dict_1, &local_err)); 279 279 g_assert(!local_err); 280 280 check_equal(dict_crumpled, dict_nested); 281 281
+1 -1
tests/check-qstring.c
··· 79 79 QString *qstring; 80 80 81 81 qstring = qstring_from_str("foo"); 82 - g_assert(qobject_to_qstring(QOBJECT(qstring)) == qstring); 82 + g_assert(qobject_to(QString, QOBJECT(qstring)) == qstring); 83 83 84 84 QDECREF(qstring); 85 85 }
+7 -7
tests/device-introspect-test.c
··· 52 52 QListEntry *e; 53 53 54 54 QLIST_FOREACH_ENTRY(types, e) { 55 - QDict *d = qobject_to_qdict(qlist_entry_obj(e)); 55 + QDict *d = qobject_to(QDict, qlist_entry_obj(e)); 56 56 const char *name = qdict_get_str(d, "name"); 57 57 QINCREF(d); 58 58 qdict_put(index, name, d); ··· 85 85 QListEntry *e; 86 86 87 87 QLIST_FOREACH_ENTRY(types, e) { 88 - QDict *d = qobject_to_qdict(qlist_entry_obj(e)); 88 + QDict *d = qobject_to(QDict, qlist_entry_obj(e)); 89 89 const char *ename = qdict_get_str(d, "name"); 90 90 if (!strcmp(ename, name)) { 91 91 return d; ··· 151 151 index = qom_type_index(types); 152 152 153 153 QLIST_FOREACH_ENTRY(types, e) { 154 - QDict *d = qobject_to_qdict(qlist_entry_obj(e)); 154 + QDict *d = qobject_to(QDict, qlist_entry_obj(e)); 155 155 const char *name = qdict_get_str(d, "name"); 156 156 157 157 g_assert(qom_has_parent(index, name, parent)); ··· 173 173 non_abstract = qom_list_types(NULL, false); 174 174 175 175 QLIST_FOREACH_ENTRY(all_types, e) { 176 - QDict *d = qobject_to_qdict(qlist_entry_obj(e)); 176 + QDict *d = qobject_to(QDict, qlist_entry_obj(e)); 177 177 const char *name = qdict_get_str(d, "name"); 178 178 bool abstract = qdict_haskey(d, "abstract") ? 179 179 qdict_get_bool(d, "abstract") : ··· 216 216 types = device_type_list(false); 217 217 218 218 QLIST_FOREACH_ENTRY(types, entry) { 219 - type = qdict_get_try_str(qobject_to_qdict(qlist_entry_obj(entry)), 220 - "name"); 219 + type = qdict_get_try_str(qobject_to(QDict, qlist_entry_obj(entry)), 220 + "name"); 221 221 g_assert(type); 222 222 test_one_device(type); 223 223 } ··· 238 238 index = qom_type_index(all_types); 239 239 240 240 QLIST_FOREACH_ENTRY(all_types, e) { 241 - QDict *d = qobject_to_qdict(qlist_entry_obj(e)); 241 + QDict *d = qobject_to(QDict, qlist_entry_obj(e)); 242 242 const char *name = qdict_get_str(d, "name"); 243 243 244 244 /*
+3 -3
tests/libqtest.c
··· 430 430 } 431 431 432 432 g_assert(!qmp->response); 433 - qmp->response = qobject_to_qdict(obj); 433 + qmp->response = qobject_to(QDict, obj); 434 434 g_assert(qmp->response); 435 435 } 436 436 ··· 1008 1008 g_assert(list); 1009 1009 1010 1010 for (p = qlist_first(list); p; p = qlist_next(p)) { 1011 - minfo = qobject_to_qdict(qlist_entry_obj(p)); 1011 + minfo = qobject_to(QDict, qlist_entry_obj(p)); 1012 1012 g_assert(minfo); 1013 1013 qobj = qdict_get(minfo, "name"); 1014 1014 g_assert(qobj); 1015 - qstr = qobject_to_qstring(qobj); 1015 + qstr = qobject_to(QString, qobj); 1016 1016 g_assert(qstr); 1017 1017 mname = qstring_get_str(qstr); 1018 1018 cb(mname);
+4 -4
tests/numa-test.c
··· 98 98 QDict *cpu, *props; 99 99 int64_t cpu_idx, node; 100 100 101 - cpu = qobject_to_qdict(e); 101 + cpu = qobject_to(QDict, e); 102 102 g_assert(qdict_haskey(cpu, "CPU")); 103 103 g_assert(qdict_haskey(cpu, "props")); 104 104 ··· 140 140 QDict *cpu, *props; 141 141 int64_t socket, core, thread, node; 142 142 143 - cpu = qobject_to_qdict(e); 143 + cpu = qobject_to(QDict, e); 144 144 g_assert(qdict_haskey(cpu, "props")); 145 145 props = qdict_get_qdict(cpu, "props"); 146 146 ··· 193 193 QDict *cpu, *props; 194 194 int64_t core, node; 195 195 196 - cpu = qobject_to_qdict(e); 196 + cpu = qobject_to(QDict, e); 197 197 g_assert(qdict_haskey(cpu, "props")); 198 198 props = qdict_get_qdict(cpu, "props"); 199 199 ··· 236 236 QDict *cpu, *props; 237 237 int64_t thread, node; 238 238 239 - cpu = qobject_to_qdict(e); 239 + cpu = qobject_to(QDict, e); 240 240 g_assert(qdict_haskey(cpu, "props")); 241 241 props = qdict_get_qdict(cpu, "props"); 242 242
+2 -2
tests/qom-test.c
··· 62 62 } 63 63 64 64 g_assert(qdict_haskey(response, "return")); 65 - list = qobject_to_qlist(qdict_get(response, "return")); 65 + list = qobject_to(QList, qdict_get(response, "return")); 66 66 QLIST_FOREACH_ENTRY(list, entry) { 67 - tuple = qobject_to_qdict(qlist_entry_obj(entry)); 67 + tuple = qobject_to(QDict, qlist_entry_obj(entry)); 68 68 bool is_child = strstart(qdict_get_str(tuple, "type"), "child<", NULL); 69 69 bool is_link = strstart(qdict_get_str(tuple, "type"), "link<", NULL); 70 70
+1 -1
tests/test-char.c
··· 319 319 g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_abort)); 320 320 321 321 addr = object_property_get_qobject(OBJECT(chr), "addr", &error_abort); 322 - qdict = qobject_to_qdict(addr); 322 + qdict = qobject_to(QDict, addr); 323 323 port = qdict_get_str(qdict, "port"); 324 324 tmp = g_strdup_printf("tcp:127.0.0.1:%s", port); 325 325 QDECREF(qdict);
+4 -4
tests/test-keyval.c
··· 195 195 196 196 g_assert(qlist); 197 197 for (i = 0; i < ARRAY_SIZE(expected); i++) { 198 - qstr = qobject_to_qstring(qlist_pop(qlist)); 198 + qstr = qobject_to(QString, qlist_pop(qlist)); 199 199 g_assert(qstr); 200 200 g_assert_cmpstr(qstring_get_str(qstr), ==, expected[i]); 201 201 QDECREF(qstr); ··· 654 654 QDECREF(qdict); 655 655 visit_start_struct(v, NULL, NULL, 0, &error_abort); 656 656 visit_type_any(v, "a", &any, &error_abort); 657 - qlist = qobject_to_qlist(any); 657 + qlist = qobject_to(QList, any); 658 658 g_assert(qlist); 659 - qstr = qobject_to_qstring(qlist_pop(qlist)); 659 + qstr = qobject_to(QString, qlist_pop(qlist)); 660 660 g_assert_cmpstr(qstring_get_str(qstr), ==, "null"); 661 661 QDECREF(qstr); 662 - qstr = qobject_to_qstring(qlist_pop(qlist)); 662 + qstr = qobject_to(QString, qlist_pop(qlist)); 663 663 g_assert_cmpstr(qstring_get_str(qstr), ==, "1"); 664 664 g_assert(qlist_empty(qlist)); 665 665 QDECREF(qstr);
+10 -9
tests/test-qga.c
··· 297 297 /* check there is at least a cpu */ 298 298 list = qdict_get_qlist(ret, "return"); 299 299 entry = qlist_first(list); 300 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "online")); 301 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "logical-id")); 300 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "online")); 301 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "logical-id")); 302 302 303 303 QDECREF(ret); 304 304 } ··· 318 318 list = qdict_get_qlist(ret, "return"); 319 319 entry = qlist_first(list); 320 320 if (entry) { 321 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name")); 322 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint")); 323 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type")); 324 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk")); 321 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "name")); 322 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "mountpoint")); 323 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "type")); 324 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "disk")); 325 325 } 326 326 327 327 QDECREF(ret); ··· 363 363 entry = qlist_first(list); 364 364 /* newer versions of qga may return empty list without error */ 365 365 if (entry) { 366 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "phys-index")); 367 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "online")); 366 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), 367 + "phys-index")); 368 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "online")); 368 369 } 369 370 } 370 371 ··· 385 386 /* check there is at least an interface */ 386 387 list = qdict_get_qlist(ret, "return"); 387 388 entry = qlist_first(list); 388 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name")); 389 + g_assert(qdict_haskey(qobject_to(QDict, entry->value), "name")); 389 390 390 391 QDECREF(ret); 391 392 }
+6 -6
tests/test-qmp-cmds.c
··· 100 100 101 101 resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); 102 102 assert(resp != NULL); 103 - assert(!qdict_haskey(qobject_to_qdict(resp), "error")); 103 + assert(!qdict_haskey(qobject_to(QDict, resp), "error")); 104 104 105 105 qobject_decref(resp); 106 106 QDECREF(req); ··· 117 117 118 118 resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); 119 119 assert(resp != NULL); 120 - assert(qdict_haskey(qobject_to_qdict(resp), "error")); 120 + assert(qdict_haskey(qobject_to(QDict, resp), "error")); 121 121 122 122 qobject_decref(resp); 123 123 QDECREF(req); ··· 131 131 132 132 resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); 133 133 assert(resp != NULL); 134 - assert(qdict_haskey(qobject_to_qdict(resp), "error")); 134 + assert(qdict_haskey(qobject_to(QDict, resp), "error")); 135 135 136 136 qobject_decref(resp); 137 137 QDECREF(req); ··· 145 145 146 146 resp_obj = qmp_dispatch(&qmp_commands, QOBJECT(req)); 147 147 assert(resp_obj); 148 - resp = qobject_to_qdict(resp_obj); 148 + resp = qobject_to(QDict, resp_obj); 149 149 assert(resp && !qdict_haskey(resp, "error")); 150 150 ret = qdict_get(resp, "return"); 151 151 assert(ret); ··· 176 176 qdict_put(req, "arguments", args); 177 177 qdict_put_str(req, "execute", "user_def_cmd2"); 178 178 179 - ret = qobject_to_qdict(test_qmp_dispatch(req)); 179 + ret = qobject_to(QDict, test_qmp_dispatch(req)); 180 180 181 181 assert(!strcmp(qdict_get_str(ret, "string0"), "blah1")); 182 182 ret_dict = qdict_get_qdict(ret, "dict1"); ··· 197 197 qdict_put(req, "arguments", args3); 198 198 qdict_put_str(req, "execute", "guest-get-time"); 199 199 200 - ret3 = qobject_to_qnum(test_qmp_dispatch(req)); 200 + ret3 = qobject_to(QNum, test_qmp_dispatch(req)); 201 201 g_assert(qnum_get_try_int(ret3, &val)); 202 202 g_assert_cmpint(val, ==, 66); 203 203 QDECREF(ret3);
+8 -8
tests/test-qmp-event.c
··· 60 60 61 61 switch (qobject_type(obj1)) { 62 62 case QTYPE_QBOOL: 63 - d->result = (qbool_get_bool(qobject_to_qbool(obj1)) == 64 - qbool_get_bool(qobject_to_qbool(obj2))); 63 + d->result = (qbool_get_bool(qobject_to(QBool, obj1)) == 64 + qbool_get_bool(qobject_to(QBool, obj2))); 65 65 return; 66 66 case QTYPE_QNUM: 67 - g_assert(qnum_get_try_int(qobject_to_qnum(obj1), &val1)); 68 - g_assert(qnum_get_try_int(qobject_to_qnum(obj2), &val2)); 67 + g_assert(qnum_get_try_int(qobject_to(QNum, obj1), &val1)); 68 + g_assert(qnum_get_try_int(qobject_to(QNum, obj2), &val2)); 69 69 d->result = val1 == val2; 70 70 return; 71 71 case QTYPE_QSTRING: 72 - d->result = g_strcmp0(qstring_get_str(qobject_to_qstring(obj1)), 73 - qstring_get_str(qobject_to_qstring(obj2))) == 0; 72 + d->result = g_strcmp0(qstring_get_str(qobject_to(QString, obj1)), 73 + qstring_get_str(qobject_to(QString, obj2))) == 0; 74 74 return; 75 75 case QTYPE_QDICT: 76 - d_new.expect = qobject_to_qdict(obj2); 76 + d_new.expect = qobject_to(QDict, obj2); 77 77 d_new.result = true; 78 - qdict_iter(qobject_to_qdict(obj1), qdict_cmp_do_simple, &d_new); 78 + qdict_iter(qobject_to(QDict, obj1), qdict_cmp_do_simple, &d_new); 79 79 d->result = d_new.result; 80 80 return; 81 81 default:
+5 -5
tests/test-qobject-input-visitor.c
··· 479 479 480 480 v = visitor_input_test_init(data, "-42"); 481 481 visit_type_any(v, NULL, &res, &error_abort); 482 - qnum = qobject_to_qnum(res); 482 + qnum = qobject_to(QNum, res); 483 483 g_assert(qnum); 484 484 g_assert(qnum_get_try_int(qnum, &val)); 485 485 g_assert_cmpint(val, ==, -42); ··· 487 487 488 488 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); 489 489 visit_type_any(v, NULL, &res, &error_abort); 490 - qdict = qobject_to_qdict(res); 490 + qdict = qobject_to(QDict, res); 491 491 g_assert(qdict && qdict_size(qdict) == 3); 492 492 qobj = qdict_get(qdict, "integer"); 493 493 g_assert(qobj); 494 - qnum = qobject_to_qnum(qobj); 494 + qnum = qobject_to(QNum, qobj); 495 495 g_assert(qnum); 496 496 g_assert(qnum_get_try_int(qnum, &val)); 497 497 g_assert_cmpint(val, ==, -42); 498 498 qobj = qdict_get(qdict, "boolean"); 499 499 g_assert(qobj); 500 - qbool = qobject_to_qbool(qobj); 500 + qbool = qobject_to(QBool, qobj); 501 501 g_assert(qbool); 502 502 g_assert(qbool_get_bool(qbool) == true); 503 503 qobj = qdict_get(qdict, "string"); 504 504 g_assert(qobj); 505 - qstring = qobject_to_qstring(qobj); 505 + qstring = qobject_to(QString, qobj); 506 506 g_assert(qstring); 507 507 g_assert_cmpstr(qstring_get_str(qstring), ==, "foo"); 508 508 qobject_decref(res);
+27 -27
tests/test-qobject-output-visitor.c
··· 66 66 67 67 visit_type_int(data->ov, NULL, &value, &error_abort); 68 68 69 - qnum = qobject_to_qnum(visitor_get(data)); 69 + qnum = qobject_to(QNum, visitor_get(data)); 70 70 g_assert(qnum); 71 71 g_assert(qnum_get_try_int(qnum, &val)); 72 72 g_assert_cmpint(val, ==, value); ··· 80 80 81 81 visit_type_bool(data->ov, NULL, &value, &error_abort); 82 82 83 - qbool = qobject_to_qbool(visitor_get(data)); 83 + qbool = qobject_to(QBool, visitor_get(data)); 84 84 g_assert(qbool); 85 85 g_assert(qbool_get_bool(qbool) == value); 86 86 } ··· 93 93 94 94 visit_type_number(data->ov, NULL, &value, &error_abort); 95 95 96 - qnum = qobject_to_qnum(visitor_get(data)); 96 + qnum = qobject_to(QNum, visitor_get(data)); 97 97 g_assert(qnum); 98 98 g_assert(qnum_get_double(qnum) == value); 99 99 } ··· 106 106 107 107 visit_type_str(data->ov, NULL, &string, &error_abort); 108 108 109 - qstr = qobject_to_qstring(visitor_get(data)); 109 + qstr = qobject_to(QString, visitor_get(data)); 110 110 g_assert(qstr); 111 111 g_assert_cmpstr(qstring_get_str(qstr), ==, string); 112 112 } ··· 120 120 /* A null string should return "" */ 121 121 visit_type_str(data->ov, NULL, &string, &error_abort); 122 122 123 - qstr = qobject_to_qstring(visitor_get(data)); 123 + qstr = qobject_to(QString, visitor_get(data)); 124 124 g_assert(qstr); 125 125 g_assert_cmpstr(qstring_get_str(qstr), ==, ""); 126 126 } ··· 134 134 for (i = 0; i < ENUM_ONE__MAX; i++) { 135 135 visit_type_EnumOne(data->ov, "unused", &i, &error_abort); 136 136 137 - qstr = qobject_to_qstring(visitor_get(data)); 137 + qstr = qobject_to(QString, visitor_get(data)); 138 138 g_assert(qstr); 139 139 g_assert_cmpstr(qstring_get_str(qstr), ==, EnumOne_str(i)); 140 140 visitor_reset(data); ··· 167 167 168 168 visit_type_TestStruct(data->ov, NULL, &p, &error_abort); 169 169 170 - qdict = qobject_to_qdict(visitor_get(data)); 170 + qdict = qobject_to(QDict, visitor_get(data)); 171 171 g_assert(qdict); 172 172 g_assert_cmpint(qdict_size(qdict), ==, 3); 173 173 g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); ··· 206 206 207 207 visit_type_UserDefTwo(data->ov, "unused", &ud2, &error_abort); 208 208 209 - qdict = qobject_to_qdict(visitor_get(data)); 209 + qdict = qobject_to(QDict, visitor_get(data)); 210 210 g_assert(qdict); 211 211 g_assert_cmpint(qdict_size(qdict), ==, 2); 212 212 g_assert_cmpstr(qdict_get_str(qdict, "string0"), ==, strings[0]); ··· 280 280 281 281 visit_type_TestStructList(data->ov, NULL, &head, &error_abort); 282 282 283 - qlist = qobject_to_qlist(visitor_get(data)); 283 + qlist = qobject_to(QList, visitor_get(data)); 284 284 g_assert(qlist); 285 285 g_assert(!qlist_empty(qlist)); 286 286 ··· 289 289 QLIST_FOREACH_ENTRY(qlist, entry) { 290 290 QDict *qdict; 291 291 292 - qdict = qobject_to_qdict(entry->value); 292 + qdict = qobject_to(QDict, entry->value); 293 293 g_assert(qdict); 294 294 g_assert_cmpint(qdict_size(qdict), ==, 3); 295 295 g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, value_int + i); ··· 342 342 343 343 qobj = QOBJECT(qnum_from_int(-42)); 344 344 visit_type_any(data->ov, NULL, &qobj, &error_abort); 345 - qnum = qobject_to_qnum(visitor_get(data)); 345 + qnum = qobject_to(QNum, visitor_get(data)); 346 346 g_assert(qnum); 347 347 g_assert(qnum_get_try_int(qnum, &val)); 348 348 g_assert_cmpint(val, ==, -42); ··· 356 356 qobj = QOBJECT(qdict); 357 357 visit_type_any(data->ov, NULL, &qobj, &error_abort); 358 358 qobject_decref(qobj); 359 - qdict = qobject_to_qdict(visitor_get(data)); 359 + qdict = qobject_to(QDict, visitor_get(data)); 360 360 g_assert(qdict); 361 - qnum = qobject_to_qnum(qdict_get(qdict, "integer")); 361 + qnum = qobject_to(QNum, qdict_get(qdict, "integer")); 362 362 g_assert(qnum); 363 363 g_assert(qnum_get_try_int(qnum, &val)); 364 364 g_assert_cmpint(val, ==, -42); 365 - qbool = qobject_to_qbool(qdict_get(qdict, "boolean")); 365 + qbool = qobject_to(QBool, qdict_get(qdict, "boolean")); 366 366 g_assert(qbool); 367 367 g_assert(qbool_get_bool(qbool) == true); 368 - qstring = qobject_to_qstring(qdict_get(qdict, "string")); 368 + qstring = qobject_to(QString, qdict_get(qdict, "string")); 369 369 g_assert(qstring); 370 370 g_assert_cmpstr(qstring_get_str(qstring), ==, "foo"); 371 371 } ··· 382 382 tmp->u.value1.boolean = true; 383 383 384 384 visit_type_UserDefFlatUnion(data->ov, NULL, &tmp, &error_abort); 385 - qdict = qobject_to_qdict(visitor_get(data)); 385 + qdict = qobject_to(QDict, visitor_get(data)); 386 386 g_assert(qdict); 387 387 g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1"); 388 388 g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str"); ··· 406 406 tmp->u.i = 42; 407 407 408 408 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); 409 - qnum = qobject_to_qnum(visitor_get(data)); 409 + qnum = qobject_to(QNum, visitor_get(data)); 410 410 g_assert(qnum); 411 411 g_assert(qnum_get_try_int(qnum, &val)); 412 412 g_assert_cmpint(val, ==, 42); ··· 419 419 tmp->u.e = ENUM_ONE_VALUE1; 420 420 421 421 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); 422 - qstr = qobject_to_qstring(visitor_get(data)); 422 + qstr = qobject_to(QString, visitor_get(data)); 423 423 g_assert(qstr); 424 424 g_assert_cmpstr(qstring_get_str(qstr), ==, "value1"); 425 425 ··· 444 444 tmp->u.udfu.u.value1.boolean = true; 445 445 446 446 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); 447 - qdict = qobject_to_qdict(visitor_get(data)); 447 + qdict = qobject_to(QDict, visitor_get(data)); 448 448 g_assert(qdict); 449 449 g_assert_cmpint(qdict_size(qdict), ==, 4); 450 450 g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 1); ··· 466 466 visit_type_null(data->ov, "a", &null, &error_abort); 467 467 visit_check_struct(data->ov, &error_abort); 468 468 visit_end_struct(data->ov, NULL); 469 - qdict = qobject_to_qdict(visitor_get(data)); 469 + qdict = qobject_to(QDict, visitor_get(data)); 470 470 g_assert(qdict); 471 471 g_assert_cmpint(qdict_size(qdict), ==, 1); 472 472 nil = qdict_get(qdict, "a"); ··· 610 610 QList *qlist; 611 611 int i; 612 612 613 - qdict = qobject_to_qdict(qobj); 613 + qdict = qobject_to(QDict, qobj); 614 614 g_assert(qdict); 615 615 g_assert(qdict_haskey(qdict, "data")); 616 - qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data"))); 616 + qlist = qlist_copy(qobject_to(QList, qdict_get(qdict, "data"))); 617 617 618 618 switch (kind) { 619 619 case USER_DEF_NATIVE_LIST_UNION_KIND_U8: ··· 627 627 628 628 tmp = qlist_peek(qlist); 629 629 g_assert(tmp); 630 - qvalue = qobject_to_qnum(tmp); 630 + qvalue = qobject_to(QNum, tmp); 631 631 g_assert(qnum_get_try_uint(qvalue, &val)); 632 632 g_assert_cmpint(val, ==, i); 633 633 qobject_decref(qlist_pop(qlist)); ··· 651 651 652 652 tmp = qlist_peek(qlist); 653 653 g_assert(tmp); 654 - qvalue = qobject_to_qnum(tmp); 654 + qvalue = qobject_to(QNum, tmp); 655 655 g_assert(qnum_get_try_int(qvalue, &val)); 656 656 g_assert_cmpint(val, ==, i); 657 657 qobject_decref(qlist_pop(qlist)); ··· 663 663 QBool *qvalue; 664 664 tmp = qlist_peek(qlist); 665 665 g_assert(tmp); 666 - qvalue = qobject_to_qbool(tmp); 666 + qvalue = qobject_to(QBool, tmp); 667 667 g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); 668 668 qobject_decref(qlist_pop(qlist)); 669 669 } ··· 675 675 gchar str[8]; 676 676 tmp = qlist_peek(qlist); 677 677 g_assert(tmp); 678 - qvalue = qobject_to_qstring(tmp); 678 + qvalue = qobject_to(QString, tmp); 679 679 sprintf(str, "%d", i); 680 680 g_assert_cmpstr(qstring_get_str(qvalue), ==, str); 681 681 qobject_decref(qlist_pop(qlist)); ··· 690 690 691 691 tmp = qlist_peek(qlist); 692 692 g_assert(tmp); 693 - qvalue = qobject_to_qnum(tmp); 693 + qvalue = qobject_to(QNum, tmp); 694 694 g_string_printf(double_expected, "%.6f", (double)i / 3); 695 695 g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue)); 696 696 g_assert_cmpstr(double_actual->str, ==, double_expected->str);
+9 -8
tests/test-x86-cpuid-compat.c
··· 17 17 g_assert(qdict_haskey(resp, "return")); 18 18 ret = qdict_get_qlist(resp, "return"); 19 19 20 - cpu0 = qobject_to_qdict(qlist_peek(ret)); 20 + cpu0 = qobject_to(QDict, qlist_peek(ret)); 21 21 path = g_strdup(qdict_get_str(cpu0, "qom_path")); 22 22 QDECREF(resp); 23 23 return path; ··· 38 38 #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS 39 39 static bool qom_get_bool(const char *path, const char *prop) 40 40 { 41 - QBool *value = qobject_to_qbool(qom_get(path, prop)); 41 + QBool *value = qobject_to(QBool, qom_get(path, prop)); 42 42 bool b = qbool_get_bool(value); 43 43 44 44 QDECREF(value); ··· 61 61 62 62 qtest_start(args->cmdline); 63 63 path = get_cpu0_qom_path(); 64 - value = qobject_to_qnum(qom_get(path, args->property)); 64 + value = qobject_to(QNum, qom_get(path, args->property)); 65 65 g_assert(qnum_get_try_int(value, &val)); 66 66 g_assert_cmpint(val, ==, args->expected_value); 67 67 qtest_end(); ··· 105 105 const QListEntry *e; 106 106 107 107 for (e = qlist_first(features); e; e = qlist_next(e)) { 108 - QDict *w = qobject_to_qdict(qlist_entry_obj(e)); 108 + QDict *w = qobject_to(QDict, qlist_entry_obj(e)); 109 109 const char *rreg = qdict_get_str(w, "cpuid-register"); 110 110 uint32_t reax = qdict_get_int(w, "cpuid-input-eax"); 111 111 bool has_ecx = qdict_haskey(w, "cpuid-input-ecx"); ··· 116 116 recx = qdict_get_int(w, "cpuid-input-ecx"); 117 117 } 118 118 if (eax == reax && (!has_ecx || ecx == recx) && !strcmp(rreg, reg)) { 119 - g_assert(qnum_get_try_int(qobject_to_qnum(qdict_get(w, "features")), 120 - &val)); 119 + g_assert(qnum_get_try_int(qobject_to(QNum, 120 + qdict_get(w, "features")), 121 + &val)); 121 122 return val; 122 123 } 123 124 } ··· 133 134 134 135 qtest_start(args->cmdline); 135 136 path = get_cpu0_qom_path(); 136 - present = qobject_to_qlist(qom_get(path, "feature-words")); 137 - filtered = qobject_to_qlist(qom_get(path, "filtered-features")); 137 + present = qobject_to(QList, qom_get(path, "feature-words")); 138 + filtered = qobject_to(QList, qom_get(path, "filtered-features")); 138 139 value = get_feature_word(present, args->in_eax, args->in_ecx, args->reg); 139 140 value |= get_feature_word(filtered, args->in_eax, args->in_ecx, args->reg); 140 141 qtest_end();
+2 -2
util/keyval.c
··· 221 221 if (!next) { 222 222 return NULL; 223 223 } 224 - cur = qobject_to_qdict(next); 224 + cur = qobject_to(QDict, next); 225 225 assert(cur); 226 226 } 227 227 ··· 314 314 has_member = true; 315 315 } 316 316 317 - qdict = qobject_to_qdict(ent->value); 317 + qdict = qobject_to(QDict, ent->value); 318 318 if (!qdict) { 319 319 continue; 320 320 }
+1 -1
util/qemu-config.c
··· 528 528 } 529 529 530 530 QLIST_FOREACH_ENTRY(list, list_entry) { 531 - QDict *section = qobject_to_qdict(qlist_entry_obj(list_entry)); 531 + QDict *section = qobject_to(QDict, qlist_entry_obj(list_entry)); 532 532 char *opt_name; 533 533 534 534 if (!section) {
+3 -3
util/qemu-option.c
··· 919 919 920 920 switch (qobject_type(obj)) { 921 921 case QTYPE_QSTRING: 922 - value = qstring_get_str(qobject_to_qstring(obj)); 922 + value = qstring_get_str(qobject_to(QString, obj)); 923 923 break; 924 924 case QTYPE_QNUM: 925 - tmp = qnum_to_string(qobject_to_qnum(obj)); 925 + tmp = qnum_to_string(qobject_to(QNum, obj)); 926 926 value = tmp; 927 927 break; 928 928 case QTYPE_QBOOL: 929 929 pstrcpy(buf, sizeof(buf), 930 - qbool_get_bool(qobject_to_qbool(obj)) ? "on" : "off"); 930 + qbool_get_bool(qobject_to(QBool, obj)) ? "on" : "off"); 931 931 value = buf; 932 932 break; 933 933 default: