[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 01/29] block-qdict: Pacify Coverity after commit f1b3
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 01/29] block-qdict: Pacify Coverity after commit f1b34a248e9 |
Date: |
Fri, 29 Jun 2018 16:09:31 +0200 |
From: Markus Armbruster <address@hidden>
Commit f1b34a248e9 replaced less-than-obvious test in
qdict_flatten_qdict() by the obvious one. Sadly, it made something
else non-obvious: the fact that @new_key passed to qdict_put_obj()
can't be null, because that depends on the function's precondition
(target == qdict) == !prefix.
Tweak the function some more to help Coverity and human readers alike.
Fixes: CID 1393620
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qobject/block-qdict.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 36129e7379..80c653013f 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -97,7 +97,7 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target,
const char *prefix)
const QDictEntry *entry, *next;
QDict *dict_val;
QList *list_val;
- char *new_key;
+ char *key, *new_key;
entry = qdict_first(qdict);
@@ -106,10 +106,12 @@ static void qdict_flatten_qdict(QDict *qdict, QDict
*target, const char *prefix)
value = qdict_entry_value(entry);
dict_val = qobject_to(QDict, value);
list_val = qobject_to(QList, value);
- new_key = NULL;
if (prefix) {
- new_key = g_strdup_printf("%s.%s", prefix, entry->key);
+ key = new_key = g_strdup_printf("%s.%s", prefix, entry->key);
+ } else {
+ key = entry->key;
+ new_key = NULL;
}
/*
@@ -125,19 +127,17 @@ static void qdict_flatten_qdict(QDict *qdict, QDict
*target, const char *prefix)
* well advised not to modify them altogether.)
*/
if (dict_val && qdict_size(dict_val)) {
- qdict_flatten_qdict(dict_val, target,
- new_key ? new_key : entry->key);
+ qdict_flatten_qdict(dict_val, target, key);
if (target == qdict) {
qdict_del(qdict, entry->key);
}
} else if (list_val && !qlist_empty(list_val)) {
- qdict_flatten_qlist(list_val, target,
- new_key ? new_key : entry->key);
+ qdict_flatten_qlist(list_val, target, key);
if (target == qdict) {
qdict_del(qdict, entry->key);
}
} else if (target != qdict) {
- qdict_put_obj(target, new_key, qobject_ref(value));
+ qdict_put_obj(target, key, qobject_ref(value));
}
g_free(new_key);
--
2.13.6
- [Qemu-block] [PULL 00/29] Block layer patches, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 03/29] qapi/job: The next release will be 3.0, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 04/29] usb-storage: Add rerror/werror properties, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 02/29] block/crypto: Pacify Coverity after commit f853465aacb, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 01/29] block-qdict: Pacify Coverity after commit f1b34a248e9,
Kevin Wolf <=
- [Qemu-block] [PULL 05/29] hw/block/nvme: add optional parameter num_queues for nvme device, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 08/29] qcow2: Remove coroutine trampoline for preallocate_co(), Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 06/29] qcow2: Fix qcow2_truncate() error return value, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 10/29] block: Use tracked request for truncate, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 07/29] block: Convert .bdrv_truncate callback to coroutine_fn, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 11/29] file-posix: Make .bdrv_co_truncate asynchronous, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 09/29] block: Move bdrv_truncate() implementation to io.c, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 13/29] block: Move request tracking to children in copy offloading, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 12/29] qcow2: Remove dead check on !ret, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 14/29] block/crypto: Simplify block_crypto_{open, create}_opts_init(), Kevin Wolf, 2018/06/29