From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [RFC 1/7] qdict: Add qdict_set_default_bool()
Date: Wed, 2 May 2018 23:32:13 +0200 [thread overview]
Message-ID: <20180502213219.7842-2-mreitz@redhat.com> (raw)
In-Reply-To: <20180502213219.7842-1-mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/qapi/qmp/qdict.h | 1 +
qobject/qdict.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 2cc3e906f7..a6fb89302d 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -69,6 +69,7 @@ const char *qdict_get_try_str(const QDict *qdict, const char *key);
void qdict_copy_default(QDict *dst, QDict *src, const char *key);
void qdict_set_default_str(QDict *dst, const char *key, const char *val);
+void qdict_set_default_bool(QDict *dst, const char *key, bool val);
QDict *qdict_clone_shallow(const QDict *src);
void qdict_flatten(QDict *qdict);
diff --git a/qobject/qdict.c b/qobject/qdict.c
index d1997a0d8a..5c25da36b3 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -498,6 +498,19 @@ void qdict_set_default_str(QDict *dst, const char *key, const char *val)
qdict_put_str(dst, key, val);
}
+/**
+ * qdict_set_default_bool(): If no entry mapped by 'key' exists in
+ * 'dst' yet, a new QBool initialized by 'val' is put there.
+ */
+void qdict_set_default_bool(QDict *dst, const char *key, bool val)
+{
+ if (qdict_haskey(dst, key)) {
+ return;
+ }
+
+ qdict_put_bool(dst, key, val);
+}
+
static void qdict_flatten_qdict(QDict *qdict, QDict *target,
const char *prefix);
--
2.14.3
next prev parent reply other threads:[~2018-05-02 21:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 21:32 [Qemu-devel] [RFC 0/7] block: Try to use correctly typed blockdev options Max Reitz
2018-05-02 21:32 ` Max Reitz [this message]
2018-05-02 21:32 ` [Qemu-devel] [RFC 2/7] block: Let change-medium add detect-zeroes as bool Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 3/7] block: Make use of qdict_set_default_bool() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 4/7] block: Add bdrv_open_string_opts() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 5/7] block: Add blk_new_open_string_opts() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 6/7] block: Use {blk_new, bdrv}_open_string_opts() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 7/7] iotests: Test internal option typing Max Reitz
2018-05-02 21:36 ` [Qemu-devel] [Qemu-block] [RFC 0/7] block: Try to use correctly typed blockdev options Max Reitz
2018-05-03 8:16 ` [Qemu-devel] " Markus Armbruster
2018-05-04 15:53 ` Max Reitz
2018-05-04 16:11 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180502213219.7842-2-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.