From c1ad032a88fbfca99e1fdffd5b19ff6d4c9adb0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 7 Mar 2018 17:19:33 -0500 Subject: [PATCH] qlit: Replace open-coded qnum_get_int() by call Bonus: rids us of a side effect in an assertion. Backports commit 5f4bd8093671962093d9ec7d57ef65244b270dd4 from qemu --- qemu/qobject/qlit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qemu/qobject/qlit.c b/qemu/qobject/qlit.c index 8a3726b0..bbe707d2 100644 --- a/qemu/qobject/qlit.c +++ b/qemu/qobject/qlit.c @@ -15,6 +15,7 @@ #include "qemu/osdep.h" +#include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qlit.h" @@ -47,8 +48,6 @@ static void compare_helper(QObject *obj, void *opaque) bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) { - int64_t val; - if (!rhs || lhs->type != qobject_type(rhs)) { return false; } @@ -57,8 +56,7 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) case QTYPE_QBOOL: return lhs->value.qbool == qbool_get_bool(qobject_to_qbool(rhs)); case QTYPE_QNUM: - g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val)); - return lhs->value.qnum == val; + 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);