Commit 7dc847eb authored by Max Reitz's avatar Max Reitz Committed by Eric Blake
Browse files

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: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
Message-Id: <20180224154033.29559-4-mreitz@redhat.com>
Reviewed-by: default avatarEric 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: default avatarEric Blake <eblake@redhat.com>
parent 1a56b1e2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1457,7 +1457,7 @@ static QDict *parse_json_filename(const char *filename, Error **errp)
        return NULL;
    }

    options = qobject_to_qdict(options_obj);
    options = qobject_to(QDict, options_obj);
    if (!options) {
        qobject_decref(options_obj);
        error_setg(errp, "Invalid JSON object given");
@@ -2433,7 +2433,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
        }
        visit_complete(v, &obj);

        qdict = qobject_to_qdict(obj);
        qdict = qobject_to(QDict, obj);
        qdict_flatten(qdict);

        /* bdrv_open_inherit() defaults to the values in bdrv_flags (for
+1 −1
Original line number Diff line number Diff line
@@ -647,7 +647,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,

    qobj = qdict_crumple(qdict, errp);
    QDECREF(qdict);
    qdict = qobject_to_qdict(qobj);
    qdict = qobject_to(QDict, qobj);
    if (qdict == NULL) {
        ret = -EINVAL;
        goto done;
+6 −6
Original line number Diff line number Diff line
@@ -647,29 +647,29 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
{
    switch (qobject_type(obj)) {
        case QTYPE_QNUM: {
            QNum *value = qobject_to_qnum(obj);
            QNum *value = qobject_to(QNum, obj);
            char *tmp = qnum_to_string(value);
            func_fprintf(f, "%s", tmp);
            g_free(tmp);
            break;
        }
        case QTYPE_QSTRING: {
            QString *value = qobject_to_qstring(obj);
            QString *value = qobject_to(QString, obj);
            func_fprintf(f, "%s", qstring_get_str(value));
            break;
        }
        case QTYPE_QDICT: {
            QDict *value = qobject_to_qdict(obj);
            QDict *value = qobject_to(QDict, obj);
            dump_qdict(func_fprintf, f, comp_indent, value);
            break;
        }
        case QTYPE_QLIST: {
            QList *value = qobject_to_qlist(obj);
            QList *value = qobject_to(QList, obj);
            dump_qlist(func_fprintf, f, comp_indent, value);
            break;
        }
        case QTYPE_QBOOL: {
            QBool *value = qobject_to_qbool(obj);
            QBool *value = qobject_to(QBool, obj);
            func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
            break;
        }
@@ -730,7 +730,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,

    visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
    visit_complete(v, &obj);
    data = qdict_get(qobject_to_qdict(obj), "data");
    data = qdict_get(qobject_to(QDict, obj), "data");
    dump_qobject(func_fprintf, f, 1, data);
    qobject_decref(obj);
    visit_free(v);
+1 −1
Original line number Diff line number Diff line
@@ -996,7 +996,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,

    qobj = qdict_crumple(qdict, errp);
    QDECREF(qdict);
    qdict = qobject_to_qdict(qobj);
    qdict = qobject_to(QDict, qobj);
    if (qdict == NULL) {
        ret = -EINVAL;
        goto fail;
+1 −1
Original line number Diff line number Diff line
@@ -3125,7 +3125,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
    /* Now get the QAPI type BlockdevCreateOptions */
    qobj = qdict_crumple(qdict, errp);
    QDECREF(qdict);
    qdict = qobject_to_qdict(qobj);
    qdict = qobject_to(QDict, qobj);
    if (qdict == NULL) {
        ret = -EINVAL;
        goto finish;
Loading