From 57b7291e90aca93da41b32d264e96d313db87b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 2 Mar 2019 23:38:24 +0100 Subject: [PATCH 1/4] util/error: Remove an unnecessary NULL check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This NULL check was required while introduced in 680d16dcb79f. Later refactor added a NULL check in error_setv(), so this check is now redundant. Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190302223825.11192-2-philmd@redhat.com> Signed-off-by: Markus Armbruster --- util/error.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/util/error.c b/util/error.c index b5ccbd8eac..934a78e1b1 100644 --- a/util/error.c +++ b/util/error.c @@ -103,10 +103,6 @@ void error_setg_errno_internal(Error **errp, va_list ap; int saved_errno = errno; - if (errp == NULL) { - return; - } - va_start(ap, fmt); error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap, os_errno != 0 ? strerror(os_errno) : NULL); From ad85b0b4c737d59bcdfba1e75b9a202e12fb5349 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 13 Mar 2019 18:44:33 +0100 Subject: [PATCH 2/4] xen-block: Replace qdict_put_obj() by qdict_put() where appropriate Patch created mechanically by rerunning: $ spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h \ --dir hw/block --in-place Signed-off-by: Markus Armbruster Message-Id: <20190313174433.12966-1-armbru@redhat.com> Reviewed-by: Eric Blake Acked-by: Paul Durrant Reviewed-by: Kevin Wolf --- hw/block/xen-block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 70fc2455e8..9c722b9b95 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -771,7 +771,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id, QDict *cache_qdict = qdict_new(); qdict_put_bool(cache_qdict, "direct", true); - qdict_put_obj(file_layer, "cache", QOBJECT(cache_qdict)); + qdict_put(file_layer, "cache", cache_qdict); qdict_put_str(file_layer, "aio", "native"); } @@ -796,7 +796,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id, qdict_put_str(driver_layer, "driver", driver); g_free(driver); - qdict_put_obj(driver_layer, "file", QOBJECT(file_layer)); + qdict_put(driver_layer, "file", file_layer); g_assert(!drive->node_name); drive->node_name = xen_block_blockdev_add(drive->id, driver_layer, From 19e8ff485a25001f48d7cbfaed24663dae001df7 Mon Sep 17 00:00:00 2001 From: Liam Merwick Date: Thu, 21 Mar 2019 11:57:52 +0000 Subject: [PATCH 3/4] json: Fix off-by-one assert check in next_state() The assert checking if the value of lexer->state in next_state(), which is used as an index to the 'json_lexer' array, incorrectly checks for an index value less than or equal to ARRAY_SIZE(json_lexer). Fix assert so that it just checks for an index less than the array size. Signed-off-by: Liam Merwick Message-Id: <1553169472-25325-1-git-send-email-liam.merwick@oracle.com> Reviewed-by: Markus Armbruster Reviewed-by: Li Qiang Reviewed-by: Stefano Garzarella Signed-off-by: Markus Armbruster --- qobject/json-lexer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index a7df2093aa..632320d72d 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -266,7 +266,7 @@ static inline uint8_t next_state(JSONLexer *lexer, char ch, bool flush, { uint8_t next; - assert(lexer->state <= ARRAY_SIZE(json_lexer)); + assert(lexer->state < ARRAY_SIZE(json_lexer)); next = json_lexer[lexer->state][(uint8_t)ch]; *char_consumed = !flush && !(next & LOOKAHEAD); return next & ~LOOKAHEAD; From 413aeacd4b33f341472c153b18eeb5ff3a70239a Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Mon, 25 Mar 2019 18:47:48 +0300 Subject: [PATCH 4/4] qapi/qmp-dispatch: fix return value in do_qmp_dispatch There are no harm but just looks weird to return bool in pointer-returning function. Introduced in 69240fe62d1 with the whole failure-checking "if" chunk. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20190325154748.66381-1-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 5f812bb9f2..e2c366e09e 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -111,7 +111,7 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request, if (oob && !(cmd->options & QCO_ALLOW_OOB)) { error_setg(errp, "The command %s does not support OOB", command); - return false; + return NULL; } if (runstate_check(RUN_STATE_PRECONFIG) &&