From: Luiz Capitulino <lcapitulino@redhat.com>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 03/10] qobject: Clean up around qtype_code
Date: Fri, 8 May 2015 09:34:04 -0400 [thread overview]
Message-ID: <1431092051-31046-4-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com>
From: Markus Armbruster <armbru@redhat.com>
QTYPE_NONE is a sentinel value. No QObject has this type code.
Document it properly.
Fix dump_qobject() to abort() on QTYPE_NONE, just like for any other
invalid type code.
Fix to_json() to abort() on all invalid type codes, not just
QTYPE_MAX.
Clean up Property member qtype's type: it's a qtype_code.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
block/qapi.c | 3 ---
include/hw/qdev-core.h | 2 +-
include/qapi/qmp/qobject.h | 2 +-
qobject/qjson.c | 3 +--
4 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index 063dd1b..18d2b95 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -523,9 +523,6 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
QDECREF(value);
break;
}
- case QTYPE_NONE:
- break;
- case QTYPE_MAX:
default:
abort();
}
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4e673f9..9a0ee30 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -226,7 +226,7 @@ struct Property {
PropertyInfo *info;
int offset;
uint8_t bitnr;
- uint8_t qtype;
+ qtype_code qtype;
int64_t defval;
int arrayoffset;
PropertyInfo *arrayinfo;
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index d0bbc7c..0991296 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -36,7 +36,7 @@
#include <assert.h>
typedef enum {
- QTYPE_NONE,
+ QTYPE_NONE, /* sentinel value, no QObject has this type code */
QTYPE_QINT,
QTYPE_QSTRING,
QTYPE_QDICT,
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 12c576d..f2857c1 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -260,9 +260,8 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
}
case QTYPE_QERROR:
/* XXX: should QError be emitted? */
- case QTYPE_NONE:
break;
- case QTYPE_MAX:
+ default:
abort();
}
}
--
1.9.3
next prev parent reply other threads:[~2015-05-08 13:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 13:34 [Qemu-devel] [PULL 00/10] QMP queue Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 01/10] monitor: add memory search commands s, sp Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 02/10] QJSON: Use OBJECT_CHECK Luiz Capitulino
2015-05-08 13:34 ` Luiz Capitulino [this message]
2015-05-08 13:34 ` [Qemu-devel] [PULL 04/10] qobject: Add a special null QObject Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 05/10] json-parser: Accept 'null' in QMP Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 06/10] MAINTAINERS: New maintainer for QMP and QAPI Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 07/10] scripts: qmp-shell: refactor helpers Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 08/10] scripts: qmp-shell: Expand support for QMP expressions Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 09/10] scripts: qmp-shell: add transaction subshell Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 10/10] scripts: qmp-shell: Add verbose flag Luiz Capitulino
2015-05-11 12:53 ` [Qemu-devel] [PULL 00/10] QMP queue Peter Maydell
2015-05-11 13:17 ` Luiz Capitulino
2015-05-12 9:40 ` Peter Maydell
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=1431092051-31046-4-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=peter.maydell@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).