Commit de6e7951 authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

qobject: Drop useless QObject casts



We have macros in place to make it less verbose to add a subtype
of QObject to both QDict and QList. While we have made cleanups
like this in the past (see commit fcfcd8ff, for example), having
it be automated by Coccinelle makes it easier to maintain.

Patch created mechanically via:
  spatch --sp-file scripts/coccinelle/qobject.cocci \
    --macro-file scripts/cocci-macro-file.h --dir . --in-place
then I verified that no manual touchups were required.

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-5-eblake@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent a2f3453e
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -4712,11 +4712,9 @@ void bdrv_refresh_filename(BlockDriverState *bs)
         * contain a representation of the filename, therefore the following
         * suffices without querying the (exact_)filename of this BDS. */
        if (bs->file->bs->full_open_options) {
            qdict_put_obj(opts, "driver",
                          QOBJECT(qstring_from_str(drv->format_name)));
            qdict_put(opts, "driver", qstring_from_str(drv->format_name));
            QINCREF(bs->file->bs->full_open_options);
            qdict_put_obj(opts, "file",
                          QOBJECT(bs->file->bs->full_open_options));
            qdict_put(opts, "file", bs->file->bs->full_open_options);

            bs->full_open_options = opts;
        } else {
@@ -4732,8 +4730,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)

        opts = qdict_new();
        append_open_options(opts, bs);
        qdict_put_obj(opts, "driver",
                      QOBJECT(qstring_from_str(drv->format_name)));
        qdict_put(opts, "driver", qstring_from_str(drv->format_name));

        if (bs->exact_filename[0]) {
            /* This may not work for all block protocol drivers (some may
@@ -4743,8 +4740,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
             * needs some special format of the options QDict, it needs to
             * implement the driver-specific bdrv_refresh_filename() function.
             */
            qdict_put_obj(opts, "filename",
                          QOBJECT(qstring_from_str(bs->exact_filename)));
            qdict_put(opts, "filename", qstring_from_str(bs->exact_filename));
        }

        bs->full_open_options = opts;
+2 −2
Original line number Diff line number Diff line
@@ -693,10 +693,10 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
    }

    opts = qdict_new();
    qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkdebug")));
    qdict_put(opts, "driver", qstring_from_str("blkdebug"));

    QINCREF(bs->file->bs->full_open_options);
    qdict_put_obj(opts, "image", QOBJECT(bs->file->bs->full_open_options));
    qdict_put(opts, "image", bs->file->bs->full_open_options);

    for (e = qdict_first(options); e; e = qdict_next(options, e)) {
        if (strcmp(qdict_entry_key(e), "x-image")) {
+3 −4
Original line number Diff line number Diff line
@@ -288,13 +288,12 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
        && s->test_file->bs->full_open_options)
    {
        QDict *opts = qdict_new();
        qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify")));
        qdict_put(opts, "driver", qstring_from_str("blkverify"));

        QINCREF(bs->file->bs->full_open_options);
        qdict_put_obj(opts, "raw", QOBJECT(bs->file->bs->full_open_options));
        qdict_put(opts, "raw", bs->file->bs->full_open_options);
        QINCREF(s->test_file->bs->full_open_options);
        qdict_put_obj(opts, "test",
                      QOBJECT(s->test_file->bs->full_open_options));
        qdict_put(opts, "test", s->test_file->bs->full_open_options);

        bs->full_open_options = opts;
    }
+3 −3
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ static void raw_parse_filename(const char *filename, QDict *options,
     * function call can be ignored. */
    strstart(filename, "file:", &filename);

    qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
    qdict_put(options, "filename", qstring_from_str(filename));
}

static QemuOptsList raw_runtime_opts = {
@@ -2155,7 +2155,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,
    /* The prefix is optional, just as for "file". */
    strstart(filename, "host_device:", &filename);

    qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
    qdict_put(options, "filename", qstring_from_str(filename));
}

static bool hdev_is_sg(BlockDriverState *bs)
@@ -2454,7 +2454,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options,
    /* The prefix is optional, just as for "file". */
    strstart(filename, "host_cdrom:", &filename);

    qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
    qdict_put(options, "filename", qstring_from_str(filename));
}
#endif

+2 −2
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ static void raw_parse_filename(const char *filename, QDict *options,
     * function call can be ignored. */
    strstart(filename, "file:", &filename);

    qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
    qdict_put(options, "filename", qstring_from_str(filename));
}

static QemuOptsList raw_runtime_opts = {
@@ -668,7 +668,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,
    /* The prefix is optional, just as for "file". */
    strstart(filename, "host_device:", &filename);

    qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
    qdict_put(options, "filename", qstring_from_str(filename));
}

static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
Loading