diff options
author | Kevin Wolf | 2017-11-17 18:24:30 +0100 |
---|---|---|
committer | Kevin Wolf | 2017-11-17 18:24:30 +0100 |
commit | d5a49c6e7d9e42059450674ec845b7bc0d62cb7e (patch) | |
tree | 8f51bb1e380876bfa0a8310cd3ab0ed4d953efac /qobject/qobject.c | |
parent | qcow2: fix image corruption on commit with persistent bitmap (diff) | |
parent | iotests: Make 087 pass without AIO enabled (diff) | |
download | qemu-d5a49c6e7d9e42059450674ec845b7bc0d62cb7e.tar.gz qemu-d5a49c6e7d9e42059450674ec845b7bc0d62cb7e.tar.xz qemu-d5a49c6e7d9e42059450674ec845b7bc0d62cb7e.zip |
Merge remote-tracking branch 'mreitz/tags/pull-block-2017-11-17' into queue-block
Block patches for 2.11.0-rc2
# gpg: Signature made Fri Nov 17 18:22:07 2017 CET
# gpg: using RSA key F407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40
* mreitz/tags/pull-block-2017-11-17:
iotests: Make 087 pass without AIO enabled
block: Make bdrv_next() keep strong references
qcow2: Fix overly broad madvise()
qcow2: Refuse to get unaligned offsets from cache
qcow2: Add bounds check to get_refblock_offset()
block: Guard against NULL bs->drv
qcow2: Unaligned zero cluster in handle_alloc()
qcow2: check_errors are fatal
qcow2: reject unaligned offsets in write compressed
iotests: Add test for failing qemu-img commit
tests: Add check-qobject for equality tests
iotests: Add test for non-string option reopening
block: qobject_is_equal() in bdrv_reopen_prepare()
qapi: Add qobject_is_equal()
qapi/qlist: Add qlist_append_null() macro
qapi/qnull: Add own header
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qobject/qobject.c')
-rw-r--r-- | qobject/qobject.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/qobject/qobject.c b/qobject/qobject.c index b0cafb66f1..b2a536041d 100644 --- a/qobject/qobject.c +++ b/qobject/qobject.c @@ -27,3 +27,32 @@ void qobject_destroy(QObject *obj) assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX); qdestroy[obj->type](obj); } + + +static bool (*qis_equal[QTYPE__MAX])(const QObject *, const QObject *) = { + [QTYPE_NONE] = NULL, /* No such object exists */ + [QTYPE_QNULL] = qnull_is_equal, + [QTYPE_QNUM] = qnum_is_equal, + [QTYPE_QSTRING] = qstring_is_equal, + [QTYPE_QDICT] = qdict_is_equal, + [QTYPE_QLIST] = qlist_is_equal, + [QTYPE_QBOOL] = qbool_is_equal, +}; + +bool qobject_is_equal(const QObject *x, const QObject *y) +{ + /* We cannot test x == y because an object does not need to be + * equal to itself (e.g. NaN floats are not). */ + + if (!x && !y) { + return true; + } + + if (!x || !y || x->type != y->type) { + return false; + } + + assert(QTYPE_NONE < x->type && x->type < QTYPE__MAX); + + return qis_equal[x->type](x, y); +} |