* [Qemu-devel] [PATCH 0/2] Use bool for QBool @ 2015-05-15 22:24 Eric Blake 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake ` (3 more replies) 0 siblings, 4 replies; 13+ messages in thread From: Eric Blake @ 2015-05-15 22:24 UTC (permalink / raw) To: qemu-devel Cc: kwolf, berto, mst, armbru, mdroth, lcapitulino, mreitz, afaerber Passing around an 'int' for a QBool type is weird, when we already use a C99 compiler and have a sane 'bool' that does just fine. I half-debated sending this through qemu-trivial, but think it better belongs through the QMP tree. There turned out to be few enough clients that I grouped it into two patches touching a number of files each; but I'm also okay with splitting into finer-grained patches that focus on fewer files at a time if that is desired. Eric Blake (2): qobject: Use 'bool' for qbool qobject: Use 'bool' inside qdict block/qapi.c | 2 +- block/quorum.c | 4 ++-- block/vvfat.c | 4 ++-- hmp.c | 40 ++++++++++++++++++++-------------------- hw/pci/pcie_aer.c | 4 ++-- include/qapi/qmp/qbool.h | 8 ++++---- include/qapi/qmp/qdict.h | 4 ++-- monitor.c | 12 ++++++------ qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 2 +- qobject/json-parser.c | 6 +++--- qobject/qbool.c | 8 ++++---- qobject/qdict.c | 8 ++++---- qobject/qjson.c | 2 +- qom/object.c | 4 ++-- tests/check-qjson.c | 11 ++++++----- tests/test-qmp-event.c | 4 ++-- tests/test-qmp-output-visitor.c | 6 +++--- util/qemu-option.c | 2 +- 19 files changed, 67 insertions(+), 66 deletions(-) -- 2.1.0 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake @ 2015-05-15 22:24 ` Eric Blake 2015-05-16 13:30 ` Andreas Färber ` (2 more replies) 2015-05-15 22:25 ` [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict Eric Blake ` (2 subsequent siblings) 3 siblings, 3 replies; 13+ messages in thread From: Eric Blake @ 2015-05-15 22:24 UTC (permalink / raw) To: qemu-devel Cc: kwolf, berto, mst, armbru, mdroth, lcapitulino, mreitz, afaerber We require a C99 compiler, so let's use 'bool' instead of 'int' when dealing with boolean values. There are few enough clients to fix them all in one pass. Signed-off-by: Eric Blake <eblake@redhat.com> --- block/qapi.c | 2 +- block/quorum.c | 4 ++-- block/vvfat.c | 4 ++-- include/qapi/qmp/qbool.h | 8 ++++---- monitor.c | 10 +++++----- qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 2 +- qobject/json-parser.c | 6 +++--- qobject/qbool.c | 8 ++++---- qobject/qdict.c | 4 ++-- qobject/qjson.c | 2 +- qom/object.c | 4 ++-- tests/check-qjson.c | 11 ++++++----- tests/test-qmp-event.c | 4 ++-- tests/test-qmp-output-visitor.c | 4 ++-- util/qemu-option.c | 2 +- 16 files changed, 39 insertions(+), 38 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 18d2b95..666bcb2 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -514,7 +514,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f, } case QTYPE_QBOOL: { QBool *value = qobject_to_qbool(obj); - func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false"); + func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"); break; } case QTYPE_QERROR: { diff --git a/block/quorum.c b/block/quorum.c index f91ef75..0e419ac 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1053,9 +1053,9 @@ static void quorum_refresh_filename(BlockDriverState *bs) qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD, QOBJECT(qint_from_int(s->threshold))); qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY, - QOBJECT(qbool_from_int(s->is_blkverify))); + QOBJECT(qbool_from_bool(s->is_blkverify))); qdict_put_obj(opts, QUORUM_OPT_REWRITE, - QOBJECT(qbool_from_int(s->rewrite_corrupted))); + QOBJECT(qbool_from_bool(s->rewrite_corrupted))); qdict_put_obj(opts, "children", QOBJECT(children)); bs->full_open_options = opts; diff --git a/block/vvfat.c b/block/vvfat.c index e803589..f3e3d49 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1059,8 +1059,8 @@ static void vvfat_parse_filename(const char *filename, QDict *options, /* Fill in the options QDict */ qdict_put(options, "dir", qstring_from_str(filename)); qdict_put(options, "fat-type", qint_from_int(fat_type)); - qdict_put(options, "floppy", qbool_from_int(floppy)); - qdict_put(options, "rw", qbool_from_int(rw)); + qdict_put(options, "floppy", qbool_from_bool(floppy)); + qdict_put(options, "rw", qbool_from_bool(rw)); } static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h index c4eaab9..4aa6be3 100644 --- a/include/qapi/qmp/qbool.h +++ b/include/qapi/qmp/qbool.h @@ -14,16 +14,16 @@ #ifndef QBOOL_H #define QBOOL_H -#include <stdint.h> +#include <stdbool.h> #include "qapi/qmp/qobject.h" typedef struct QBool { QObject_HEAD; - int value; + bool value; } QBool; -QBool *qbool_from_int(int value); -int qbool_get_int(const QBool *qb); +QBool *qbool_from_bool(bool value); +bool qbool_get_bool(const QBool *qb); QBool *qobject_to_qbool(const QObject *obj); #endif /* QBOOL_H */ diff --git a/monitor.c b/monitor.c index b2561e1..c17d874 100644 --- a/monitor.c +++ b/monitor.c @@ -3986,7 +3986,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, case 'b': { const char *beg; - int val; + bool val; while (qemu_isspace(*p)) { p++; @@ -3996,14 +3996,14 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, p++; } if (p - beg == 2 && !memcmp(beg, "on", p - beg)) { - val = 1; + val = true; } else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) { - val = 0; + val = false; } else { monitor_printf(mon, "Expected 'on' or 'off'\n"); goto fail; } - qdict_put(qdict, key, qbool_from_int(val)); + qdict_put(qdict, key, qbool_from_bool(val)); } break; case '-': @@ -4034,7 +4034,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, } else { /* has option */ p++; - qdict_put(qdict, key, qbool_from_int(1)); + qdict_put(qdict, key, qbool_from_bool(true)); } } } diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index d861206..f6dab1a 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -248,7 +248,7 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name, return; } - *obj = qbool_get_int(qobject_to_qbool(qobj)); + *obj = qbool_get_bool(qobject_to_qbool(qobj)); } static void qmp_input_type_str(Visitor *v, char **obj, const char *name, diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 96b3384..7e0f7ce 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -166,7 +166,7 @@ static void qmp_output_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) { QmpOutputVisitor *qov = to_qov(v); - qmp_output_add(qov, name, qbool_from_int(*obj)); + qmp_output_add(qov, name, qbool_from_bool(*obj)); } static void qmp_output_type_str(Visitor *v, char **obj, const char *name, diff --git a/qobject/json-parser.c b/qobject/json-parser.c index 717cb8f..015d785 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -558,9 +558,9 @@ static QObject *parse_keyword(JSONParserContext *ctxt) } if (token_is_keyword(token, "true")) { - ret = QOBJECT(qbool_from_int(true)); + ret = QOBJECT(qbool_from_bool(true)); } else if (token_is_keyword(token, "false")) { - ret = QOBJECT(qbool_from_int(false)); + ret = QOBJECT(qbool_from_bool(false)); } else if (token_is_keyword(token, "null")) { ret = qnull(); } else { @@ -593,7 +593,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap) if (token_is_escape(token, "%p")) { obj = va_arg(*ap, QObject *); } else if (token_is_escape(token, "%i")) { - obj = QOBJECT(qbool_from_int(va_arg(*ap, int))); + obj = QOBJECT(qbool_from_bool(va_arg(*ap, int))); } else if (token_is_escape(token, "%d")) { obj = QOBJECT(qint_from_int(va_arg(*ap, int))); } else if (token_is_escape(token, "%ld")) { diff --git a/qobject/qbool.c b/qobject/qbool.c index a3d2afa..5ff69f0 100644 --- a/qobject/qbool.c +++ b/qobject/qbool.c @@ -23,11 +23,11 @@ static const QType qbool_type = { }; /** - * qbool_from_int(): Create a new QBool from an int + * qbool_from_bool(): Create a new QBool from a bool * * Return strong reference. */ -QBool *qbool_from_int(int value) +QBool *qbool_from_bool(bool value) { QBool *qb; @@ -39,9 +39,9 @@ QBool *qbool_from_int(int value) } /** - * qbool_get_int(): Get the stored int + * qbool_get_bool(): Get the stored bool */ -int qbool_get_int(const QBool *qb) +bool qbool_get_bool(const QBool *qb) { return qb->value; } diff --git a/qobject/qdict.c b/qobject/qdict.c index ea239f0..d181969 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -244,7 +244,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key) int qdict_get_bool(const QDict *qdict, const char *key) { QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL); - return qbool_get_int(qobject_to_qbool(obj)); + return qbool_get_bool(qobject_to_qbool(obj)); } /** @@ -322,7 +322,7 @@ int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value) if (!obj || qobject_type(obj) != QTYPE_QBOOL) return def_value; - return qbool_get_int(qobject_to_qbool(obj)); + return qbool_get_bool(qobject_to_qbool(obj)); } /** diff --git a/qobject/qjson.c b/qobject/qjson.c index 846733d..f022edc 100644 --- a/qobject/qjson.c +++ b/qobject/qjson.c @@ -254,7 +254,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) case QTYPE_QBOOL: { QBool *val = qobject_to_qbool(obj); - if (qbool_get_int(val)) { + if (qbool_get_bool(val)) { qstring_append(str, "true"); } else { qstring_append(str, "false"); diff --git a/qom/object.c b/qom/object.c index b8dff43..0b46df6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -901,7 +901,7 @@ Object *object_property_get_link(Object *obj, const char *name, void object_property_set_bool(Object *obj, bool value, const char *name, Error **errp) { - QBool *qbool = qbool_from_int(value); + QBool *qbool = qbool_from_bool(value); object_property_set_qobject(obj, QOBJECT(qbool), name, errp); QDECREF(qbool); @@ -922,7 +922,7 @@ bool object_property_get_bool(Object *obj, const char *name, error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); retval = false; } else { - retval = qbool_get_int(qbool); + retval = qbool_get_bool(qbool); } QDECREF(qbool); diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 60e5b22..1cfffa5 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1013,7 +1013,7 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) != 0); + g_assert(qbool_get_bool(qbool) == true); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), "true") == 0); @@ -1026,7 +1026,7 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) == 0); + g_assert(qbool_get_bool(qbool) == false); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), "false") == 0); @@ -1039,16 +1039,17 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) == 0); + g_assert(qbool_get_bool(qbool) == false); QDECREF(qbool); - obj = qobject_from_jsonf("%i", true); + /* Test that non-zero values other than 1 get collapsed to true */ + obj = qobject_from_jsonf("%i", 2); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) != 0); + g_assert(qbool_get_bool(qbool) == true); QDECREF(qbool); diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index cb354e6..1ee40e1 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -60,8 +60,8 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque) switch (qobject_type(obj1)) { case QTYPE_QBOOL: - d->result = (qbool_get_int(qobject_to_qbool(obj1)) == - qbool_get_int(qobject_to_qbool(obj2))); + d->result = (qbool_get_bool(qobject_to_qbool(obj1)) == + qbool_get_bool(qobject_to_qbool(obj2))); return; case QTYPE_QINT: d->result = (qint_get_int(qobject_to_qint(obj1)) == diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index f8c9367..5be8e77 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -72,7 +72,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data, obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QBOOL); - g_assert(qbool_get_int(qobject_to_qbool(obj)) == value); + g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value); qobject_decref(obj); } @@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj, tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qbool(tmp); - g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0); + g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); qobject_decref(qlist_pop(qlist)); } break; diff --git a/util/qemu-option.c b/util/qemu-option.c index fda4e5f..8a2e8e5 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -919,7 +919,7 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque) break; case QTYPE_QBOOL: pstrcpy(buf, sizeof(buf), - qbool_get_int(qobject_to_qbool(obj)) ? "on" : "off"); + qbool_get_bool(qobject_to_qbool(obj)) ? "on" : "off"); value = buf; break; default: -- 2.1.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake @ 2015-05-16 13:30 ` Andreas Färber 2015-05-16 17:13 ` Eric Blake 2015-05-19 12:59 ` Alberto Garcia 2015-06-12 5:35 ` Markus Armbruster 2 siblings, 1 reply; 13+ messages in thread From: Andreas Färber @ 2015-05-16 13:30 UTC (permalink / raw) To: Eric Blake, qemu-devel Cc: kwolf, berto, mst, armbru, mdroth, lcapitulino, mreitz Am 16.05.2015 um 00:24 schrieb Eric Blake: > We require a C99 compiler, so let's use 'bool' instead of 'int' > when dealing with boolean values. There are few enough clients > to fix them all in one pass. > > Signed-off-by: Eric Blake <eblake@redhat.com> > --- > block/qapi.c | 2 +- > block/quorum.c | 4 ++-- > block/vvfat.c | 4 ++-- > include/qapi/qmp/qbool.h | 8 ++++---- > monitor.c | 10 +++++----- > qapi/qmp-input-visitor.c | 2 +- > qapi/qmp-output-visitor.c | 2 +- > qobject/json-parser.c | 6 +++--- > qobject/qbool.c | 8 ++++---- > qobject/qdict.c | 4 ++-- > qobject/qjson.c | 2 +- > qom/object.c | 4 ++-- > tests/check-qjson.c | 11 ++++++----- > tests/test-qmp-event.c | 4 ++-- > tests/test-qmp-output-visitor.c | 4 ++-- > util/qemu-option.c | 2 +- > 16 files changed, 39 insertions(+), 38 deletions(-) [...] > diff --git a/qobject/qbool.c b/qobject/qbool.c > index a3d2afa..5ff69f0 100644 > --- a/qobject/qbool.c > +++ b/qobject/qbool.c > @@ -23,11 +23,11 @@ static const QType qbool_type = { > }; > > /** > - * qbool_from_int(): Create a new QBool from an int > + * qbool_from_bool(): Create a new QBool from a bool > * > * Return strong reference. Can you fix the syntax as follow-up please? /** * qbool_from_bool: * @value: ... * * Desc... * * Returns: ... */ > */ > -QBool *qbool_from_int(int value) > +QBool *qbool_from_bool(bool value) > { > QBool *qb; > > @@ -39,9 +39,9 @@ QBool *qbool_from_int(int value) > } > > /** > - * qbool_get_int(): Get the stored int > + * qbool_get_bool(): Get the stored bool > */ > -int qbool_get_int(const QBool *qb) > +bool qbool_get_bool(const QBool *qb) > { > return qb->value; > } [...] > diff --git a/tests/check-qjson.c b/tests/check-qjson.c > index 60e5b22..1cfffa5 100644 > --- a/tests/check-qjson.c > +++ b/tests/check-qjson.c > @@ -1013,7 +1013,7 @@ static void keyword_literal(void) > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) != 0); > + g_assert(qbool_get_bool(qbool) == true); > > str = qobject_to_json(obj); > g_assert(strcmp(qstring_get_str(str), "true") == 0); > @@ -1026,7 +1026,7 @@ static void keyword_literal(void) > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) == 0); > + g_assert(qbool_get_bool(qbool) == false); > > str = qobject_to_json(obj); > g_assert(strcmp(qstring_get_str(str), "false") == 0); > @@ -1039,16 +1039,17 @@ static void keyword_literal(void) > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) == 0); > + g_assert(qbool_get_bool(qbool) == false); > > QDECREF(qbool); > > - obj = qobject_from_jsonf("%i", true); > + /* Test that non-zero values other than 1 get collapsed to true */ > + obj = qobject_from_jsonf("%i", 2); > g_assert(obj != NULL); > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) != 0); > + g_assert(qbool_get_bool(qbool) == true); > > QDECREF(qbool); > [...] > diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c > index f8c9367..5be8e77 100644 > --- a/tests/test-qmp-output-visitor.c > +++ b/tests/test-qmp-output-visitor.c > @@ -72,7 +72,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data, > obj = qmp_output_get_qobject(data->qov); > g_assert(obj != NULL); > g_assert(qobject_type(obj) == QTYPE_QBOOL); > - g_assert(qbool_get_int(qobject_to_qbool(obj)) == value); > + g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value); > > qobject_decref(obj); > } > @@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj, > tmp = qlist_peek(qlist); > g_assert(tmp); > qvalue = qobject_to_qbool(tmp); > - g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0); > + g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); > qobject_decref(qlist_pop(qlist)); > } > break; [snip] I notice that we're inconsistent in using g_assert() vs. g_assert_cmpint(). Given that GLib has a weird GBoolean, should we add a macro qtest_assert_cmpbool() instead as follow-up? That said, Reviewed-by: Andreas Färber <afaerber@suse.de> Regards, Andreas -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-16 13:30 ` Andreas Färber @ 2015-05-16 17:13 ` Eric Blake 2015-05-18 6:42 ` Markus Armbruster 0 siblings, 1 reply; 13+ messages in thread From: Eric Blake @ 2015-05-16 17:13 UTC (permalink / raw) To: Andreas Färber, qemu-devel Cc: kwolf, berto, mst, armbru, mdroth, lcapitulino, mreitz [-- Attachment #1: Type: text/plain, Size: 1933 bytes --] On 05/16/2015 07:30 AM, Andreas Färber wrote: > Am 16.05.2015 um 00:24 schrieb Eric Blake: >> We require a C99 compiler, so let's use 'bool' instead of 'int' >> when dealing with boolean values. There are few enough clients >> to fix them all in one pass. >> >> Signed-off-by: Eric Blake <eblake@redhat.com> >> --- >> /** >> - * qbool_from_int(): Create a new QBool from an int >> + * qbool_from_bool(): Create a new QBool from a bool >> * >> * Return strong reference. > > Can you fix the syntax as follow-up please? > > /** > * qbool_from_bool: > * @value: ... > * > * Desc... > * > * Returns: ... > */ Sure, I can do that over all the qboject files, as a new patch. >> @@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj, >> tmp = qlist_peek(qlist); >> g_assert(tmp); >> qvalue = qobject_to_qbool(tmp); >> - g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0); >> + g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); >> qobject_decref(qlist_pop(qlist)); >> } >> break; > [snip] > > I notice that we're inconsistent in using g_assert() vs. > g_assert_cmpint(). Given that GLib has a weird GBoolean, should we add a > macro qtest_assert_cmpbool() instead as follow-up? We aren't even touching GBoolean (qbool_get_bool now returns 'bool', not GBoolean; and bool promotes just fine to int under C rules), so I don't see the point to making any further changes here. Or are you proposing that the new macro would do something like 'expecting "true" but got "false"' instead of g_assert_cmpint() collapsing things to 0 and 1? > > That said, > > Reviewed-by: Andreas Färber <afaerber@suse.de> > > Regards, > Andreas > -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-16 17:13 ` Eric Blake @ 2015-05-18 6:42 ` Markus Armbruster 0 siblings, 0 replies; 13+ messages in thread From: Markus Armbruster @ 2015-05-18 6:42 UTC (permalink / raw) To: Eric Blake Cc: kwolf, berto, mst, mdroth, qemu-devel, mreitz, lcapitulino, Andreas Färber Eric Blake <eblake@redhat.com> writes: > On 05/16/2015 07:30 AM, Andreas Färber wrote: >> Am 16.05.2015 um 00:24 schrieb Eric Blake: >>> We require a C99 compiler, so let's use 'bool' instead of 'int' >>> when dealing with boolean values. There are few enough clients >>> to fix them all in one pass. >>> >>> Signed-off-by: Eric Blake <eblake@redhat.com> >>> --- > >>> /** >>> - * qbool_from_int(): Create a new QBool from an int >>> + * qbool_from_bool(): Create a new QBool from a bool >>> * >>> * Return strong reference. */ >> >> Can you fix the syntax as follow-up please? >> >> /** >> * qbool_from_bool: >> * @value: ... >> * >> * Desc... >> * >> * Returns: ... >> */ > > Sure, I can do that over all the qboject files, as a new patch. Please don't, it's an egregious waste of screen space and the reader's mental energy. We're not using GTK-Doc for anything, and as long as we don't, I'm unwilling to pay its price of admission. If a maintainer prefers to enforce GTK-Doc comment syntax in his subsystem, I won't argue. In the (few) places I maintain, I'll insist on readable, concise comments. The @sigils are welcome, repeating obvious things and other waste of space is not. For what it's worth, Kevin shared this sentiment last time we discussed it. Luiz's call, because he's the maintainer. >>> @@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj, >>> tmp = qlist_peek(qlist); >>> g_assert(tmp); >>> qvalue = qobject_to_qbool(tmp); >>> - g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0); >>> + g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); >>> qobject_decref(qlist_pop(qlist)); >>> } >>> break; >> [snip] >> >> I notice that we're inconsistent in using g_assert() vs. >> g_assert_cmpint(). Given that GLib has a weird GBoolean, should we add a >> macro qtest_assert_cmpbool() instead as follow-up? > > We aren't even touching GBoolean (qbool_get_bool now returns 'bool', not > GBoolean; and bool promotes just fine to int under C rules), so I don't > see the point to making any further changes here. Or are you proposing > that the new macro would do something like 'expecting "true" but got > "false"' instead of g_assert_cmpint() collapsing things to 0 and 1? Promoting to int here is just fine with me. Andreas is right on GBoolean of course. It's a relic that has become a trap for the unwary. Let's stay away from it as much as we can. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake 2015-05-16 13:30 ` Andreas Färber @ 2015-05-19 12:59 ` Alberto Garcia 2015-06-12 5:35 ` Markus Armbruster 2 siblings, 0 replies; 13+ messages in thread From: Alberto Garcia @ 2015-05-19 12:59 UTC (permalink / raw) To: Eric Blake, qemu-devel Cc: kwolf, mst, armbru, mdroth, lcapitulino, mreitz, afaerber On Sat 16 May 2015 12:24:59 AM CEST, Eric Blake <eblake@redhat.com> wrote: > We require a C99 compiler, so let's use 'bool' instead of 'int' > when dealing with boolean values. There are few enough clients > to fix them all in one pass. > > Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Berto ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake 2015-05-16 13:30 ` Andreas Färber 2015-05-19 12:59 ` Alberto Garcia @ 2015-06-12 5:35 ` Markus Armbruster 2015-06-12 15:38 ` Eric Blake 2 siblings, 1 reply; 13+ messages in thread From: Markus Armbruster @ 2015-06-12 5:35 UTC (permalink / raw) To: Eric Blake Cc: kwolf, berto, mst, qemu-devel, mdroth, lcapitulino, mreitz, afaerber Patch looks good to me, but it made me wonder about something. Please find the question inline. Eric Blake <eblake@redhat.com> writes: > We require a C99 compiler, so let's use 'bool' instead of 'int' > when dealing with boolean values. There are few enough clients > to fix them all in one pass. > > Signed-off-by: Eric Blake <eblake@redhat.com> [...] > diff --git a/qobject/json-parser.c b/qobject/json-parser.c > index 717cb8f..015d785 100644 > --- a/qobject/json-parser.c > +++ b/qobject/json-parser.c > @@ -558,9 +558,9 @@ static QObject *parse_keyword(JSONParserContext *ctxt) > } > > if (token_is_keyword(token, "true")) { > - ret = QOBJECT(qbool_from_int(true)); > + ret = QOBJECT(qbool_from_bool(true)); > } else if (token_is_keyword(token, "false")) { > - ret = QOBJECT(qbool_from_int(false)); > + ret = QOBJECT(qbool_from_bool(false)); > } else if (token_is_keyword(token, "null")) { > ret = qnull(); > } else { > @@ -593,7 +593,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap) > if (token_is_escape(token, "%p")) { > obj = va_arg(*ap, QObject *); > } else if (token_is_escape(token, "%i")) { > - obj = QOBJECT(qbool_from_int(va_arg(*ap, int))); > + obj = QOBJECT(qbool_from_bool(va_arg(*ap, int))); Funny: JSON_ESCAPE "%i" gets an int, but maps it to bool. See also patch to check-qjson.c below. Is this feature actually used anywhere other than the tests? > } else if (token_is_escape(token, "%d")) { > obj = QOBJECT(qint_from_int(va_arg(*ap, int))); > } else if (token_is_escape(token, "%ld")) { [...] > diff --git a/tests/check-qjson.c b/tests/check-qjson.c > index 60e5b22..1cfffa5 100644 > --- a/tests/check-qjson.c > +++ b/tests/check-qjson.c > @@ -1013,7 +1013,7 @@ static void keyword_literal(void) > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) != 0); > + g_assert(qbool_get_bool(qbool) == true); > > str = qobject_to_json(obj); > g_assert(strcmp(qstring_get_str(str), "true") == 0); > @@ -1026,7 +1026,7 @@ static void keyword_literal(void) > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) == 0); > + g_assert(qbool_get_bool(qbool) == false); > > str = qobject_to_json(obj); > g_assert(strcmp(qstring_get_str(str), "false") == 0); > @@ -1039,16 +1039,17 @@ static void keyword_literal(void) obj = qobject_from_jsonf("%i", false); g_assert(obj != NULL); > g_assert(qobject_type(obj) == QTYPE_QBOOL); > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) == 0); > + g_assert(qbool_get_bool(qbool) == false); > > QDECREF(qbool); > > - obj = qobject_from_jsonf("%i", true); > + /* Test that non-zero values other than 1 get collapsed to true */ > + obj = qobject_from_jsonf("%i", 2); > g_assert(obj != NULL); > g_assert(qobject_type(obj) == QTYPE_QBOOL); These are test test cases for JSON_ESCAPE "%i". > > qbool = qobject_to_qbool(obj); > - g_assert(qbool_get_int(qbool) != 0); > + g_assert(qbool_get_bool(qbool) == true); > > QDECREF(qbool); > [...] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool 2015-06-12 5:35 ` Markus Armbruster @ 2015-06-12 15:38 ` Eric Blake 0 siblings, 0 replies; 13+ messages in thread From: Eric Blake @ 2015-06-12 15:38 UTC (permalink / raw) To: Markus Armbruster Cc: kwolf, berto, mst, qemu-devel, mdroth, lcapitulino, mreitz, afaerber [-- Attachment #1: Type: text/plain, Size: 2191 bytes --] On 06/11/2015 11:35 PM, Markus Armbruster wrote: > Patch looks good to me, but it made me wonder about something. Please > find the question inline. > > Eric Blake <eblake@redhat.com> writes: > >> We require a C99 compiler, so let's use 'bool' instead of 'int' >> when dealing with boolean values. There are few enough clients >> to fix them all in one pass. >> >> @@ -593,7 +593,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap) >> if (token_is_escape(token, "%p")) { >> obj = va_arg(*ap, QObject *); >> } else if (token_is_escape(token, "%i")) { >> - obj = QOBJECT(qbool_from_int(va_arg(*ap, int))); >> + obj = QOBJECT(qbool_from_bool(va_arg(*ap, int))); > > Funny: JSON_ESCAPE "%i" gets an int, but maps it to bool. See also > patch to check-qjson.c below. > > Is this feature actually used anywhere other than the tests? > When using va_arg(), you have to use the type argument that things promote to when called through var-args (that is, va_arg(*ap, bool) would be a compiler warning). I don't know if anyone besides the testsuite is using %i; but I've already mentioned in another thread [1] that the correlation between... >> >> - obj = qobject_from_jsonf("%i", true); >> + /* Test that non-zero values other than 1 get collapsed to true */ >> + obj = qobject_from_jsonf("%i", 2); >> g_assert(obj != NULL); >> g_assert(qobject_type(obj) == QTYPE_QBOOL); > > These are test test cases for JSON_ESCAPE "%i". ...qobject_from_json in one file to the implementation of %i in another was very hard to trace when writing this patch, as well as the idea of getting rid of the remaining 2 out of only 3 clients of %p [1]. So it's already on my table of ideas to do a followup patch that adds documentation, and audits all clients to see what can be pruned. [1] https://lists.gnu.org/archive/html/qemu-devel/2015-05/msg04660.html -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict 2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake @ 2015-05-15 22:25 ` Eric Blake 2015-05-19 13:00 ` Alberto Garcia 2015-05-28 19:54 ` [Qemu-devel] [PATCH 0/2] Use bool for QBool Luiz Capitulino 2015-06-16 14:53 ` Markus Armbruster 3 siblings, 1 reply; 13+ messages in thread From: Eric Blake @ 2015-05-15 22:25 UTC (permalink / raw) To: qemu-devel Cc: kwolf, berto, mst, armbru, mdroth, lcapitulino, mreitz, afaerber Now that qbool is fixed, let's fix getting and setting a bool value to a qdict member to also use C99 bool rather than int. I audited all callers to ensure that the changed return type will not cause any changed semantics. Signed-off-by: Eric Blake <eblake@redhat.com> --- hmp.c | 40 ++++++++++++++++++++-------------------- hw/pci/pcie_aer.c | 4 ++-- include/qapi/qmp/qdict.h | 4 ++-- monitor.c | 2 +- qobject/qdict.c | 4 ++-- tests/test-qmp-output-visitor.c | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/hmp.c b/hmp.c index e17852d..a4ce058 100644 --- a/hmp.c +++ b/hmp.c @@ -434,8 +434,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) BlockInfoList *block_list, *info; BlockDeviceInfoList *blockdev_list, *blockdev; const char *device = qdict_get_try_str(qdict, "device"); - bool verbose = qdict_get_try_bool(qdict, "verbose", 0); - bool nodes = qdict_get_try_bool(qdict, "nodes", 0); + bool verbose = qdict_get_try_bool(qdict, "verbose", false); + bool nodes = qdict_get_try_bool(qdict, "nodes", false); bool printed = false; /* Print BlockBackend information */ @@ -991,7 +991,7 @@ void hmp_nmi(Monitor *mon, const QDict *qdict) void hmp_set_link(Monitor *mon, const QDict *qdict) { const char *name = qdict_get_str(qdict, "name"); - int up = qdict_get_bool(qdict, "up"); + bool up = qdict_get_bool(qdict, "up"); Error *err = NULL; qmp_set_link(name, up, &err); @@ -1035,8 +1035,8 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); const char *filename = qdict_get_str(qdict, "target"); const char *format = qdict_get_try_str(qdict, "format"); - int reuse = qdict_get_try_bool(qdict, "reuse", 0); - int full = qdict_get_try_bool(qdict, "full", 0); + bool reuse = qdict_get_try_bool(qdict, "reuse", false); + bool full = qdict_get_try_bool(qdict, "full", false); enum NewImageMode mode; Error *err = NULL; @@ -1065,8 +1065,8 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); const char *filename = qdict_get_str(qdict, "target"); const char *format = qdict_get_try_str(qdict, "format"); - int reuse = qdict_get_try_bool(qdict, "reuse", 0); - int full = qdict_get_try_bool(qdict, "full", 0); + bool reuse = qdict_get_try_bool(qdict, "reuse", false); + bool full = qdict_get_try_bool(qdict, "full", false); enum NewImageMode mode; Error *err = NULL; @@ -1094,7 +1094,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); const char *filename = qdict_get_try_str(qdict, "snapshot-file"); const char *format = qdict_get_try_str(qdict, "format"); - int reuse = qdict_get_try_bool(qdict, "reuse", 0); + bool reuse = qdict_get_try_bool(qdict, "reuse", false); enum NewImageMode mode; Error *err = NULL; @@ -1273,7 +1273,7 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict) void hmp_eject(Monitor *mon, const QDict *qdict) { - int force = qdict_get_try_bool(qdict, "force", 0); + bool force = qdict_get_try_bool(qdict, "force", false); const char *device = qdict_get_str(qdict, "device"); Error *err = NULL; @@ -1371,7 +1371,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict) { Error *error = NULL; const char *device = qdict_get_str(qdict, "device"); - bool force = qdict_get_try_bool(qdict, "force", 0); + bool force = qdict_get_try_bool(qdict, "force", false); qmp_block_job_cancel(device, true, force, &error); @@ -1451,9 +1451,9 @@ static void hmp_migrate_status_cb(void *opaque) void hmp_migrate(Monitor *mon, const QDict *qdict) { - int detach = qdict_get_try_bool(qdict, "detach", 0); - int blk = qdict_get_try_bool(qdict, "blk", 0); - int inc = qdict_get_try_bool(qdict, "inc", 0); + bool detach = qdict_get_try_bool(qdict, "detach", false); + bool blk = qdict_get_try_bool(qdict, "blk", false); + bool inc = qdict_get_try_bool(qdict, "inc", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL; @@ -1494,10 +1494,10 @@ void hmp_device_del(Monitor *mon, const QDict *qdict) void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *err = NULL; - int paging = qdict_get_try_bool(qdict, "paging", 0); - int zlib = qdict_get_try_bool(qdict, "zlib", 0); - int lzo = qdict_get_try_bool(qdict, "lzo", 0); - int snappy = qdict_get_try_bool(qdict, "snappy", 0); + bool paging = qdict_get_try_bool(qdict, "paging", false); + bool zlib = qdict_get_try_bool(qdict, "zlib", false); + bool lzo = qdict_get_try_bool(qdict, "lzo", false); + bool snappy = qdict_get_try_bool(qdict, "snappy", false); const char *file = qdict_get_str(qdict, "filename"); bool has_begin = qdict_haskey(qdict, "begin"); bool has_length = qdict_haskey(qdict, "length"); @@ -1723,8 +1723,8 @@ void hmp_screendump(Monitor *mon, const QDict *qdict) void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) { const char *uri = qdict_get_str(qdict, "uri"); - int writable = qdict_get_try_bool(qdict, "writable", 0); - int all = qdict_get_try_bool(qdict, "all", 0); + bool writable = qdict_get_try_bool(qdict, "writable", false); + bool all = qdict_get_try_bool(qdict, "all", false); Error *local_err = NULL; BlockInfoList *block_list, *info; SocketAddress *addr; @@ -1777,7 +1777,7 @@ exit: void hmp_nbd_server_add(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); - int writable = qdict_get_try_bool(qdict, "writable", 0); + bool writable = qdict_get_try_bool(qdict, "writable", false); Error *local_err = NULL; qmp_nbd_server_add(device, true, writable, &local_err); diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index b48c09c..d8ded2c 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -990,7 +990,7 @@ int hmp_pcie_aer_inject_error(Monitor *mon, if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) { char *e = NULL; error_status = strtoul(error_name, &e, 0); - correctable = qdict_get_try_bool(qdict, "correctable", 0); + correctable = qdict_get_try_bool(qdict, "correctable", false); if (!e || *e != '\0') { monitor_printf(mon, "invalid error status value. \"%s\"", error_name); @@ -1004,7 +1004,7 @@ int hmp_pcie_aer_inject_error(Monitor *mon, if (correctable) { err.flags |= PCIE_AER_ERR_IS_CORRECTABLE; } - if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) { + if (qdict_get_try_bool(qdict, "advisory_non_fatal", false)) { err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY; } if (qdict_haskey(qdict, "header0")) { diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index d68f4eb..a507d69 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -56,13 +56,13 @@ const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry); /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key); -int qdict_get_bool(const QDict *qdict, const char *key); +bool qdict_get_bool(const QDict *qdict, const char *key); QList *qdict_get_qlist(const QDict *qdict, const char *key); QDict *qdict_get_qdict(const QDict *qdict, const char *key); const char *qdict_get_str(const QDict *qdict, const char *key); int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value); -int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value); +bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value); const char *qdict_get_try_str(const QDict *qdict, const char *key); QDict *qdict_clone_shallow(const QDict *src); diff --git a/monitor.c b/monitor.c index c17d874..6476ac3 100644 --- a/monitor.c +++ b/monitor.c @@ -2165,7 +2165,7 @@ static void hmp_mce(Monitor *mon, const QDict *qdict) uint64_t misc = qdict_get_int(qdict, "misc"); int flags = MCE_INJECT_UNCOND_AO; - if (qdict_get_try_bool(qdict, "broadcast", 0)) { + if (qdict_get_try_bool(qdict, "broadcast", false)) { flags |= MCE_INJECT_BROADCAST; } cs = qemu_get_cpu(cpu_index); diff --git a/qobject/qdict.c b/qobject/qdict.c index d181969..4aae346 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -241,7 +241,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key) * * Return bool mapped by 'key'. */ -int qdict_get_bool(const QDict *qdict, const char *key) +bool qdict_get_bool(const QDict *qdict, const char *key) { QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL); return qbool_get_bool(qobject_to_qbool(obj)); @@ -314,7 +314,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key, * dictionary or if the stored object is not of QBool type * 'def_value' will be returned. */ -int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value) +bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value) { QObject *obj; diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 5be8e77..87ba350 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -223,7 +223,7 @@ static void test_visitor_out_struct(TestOutputVisitorData *data, qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); - g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, 0); + g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false); g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo"); QDECREF(qdict); -- 2.1.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict 2015-05-15 22:25 ` [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict Eric Blake @ 2015-05-19 13:00 ` Alberto Garcia 0 siblings, 0 replies; 13+ messages in thread From: Alberto Garcia @ 2015-05-19 13:00 UTC (permalink / raw) To: Eric Blake, qemu-devel Cc: kwolf, mst, armbru, mdroth, lcapitulino, mreitz, afaerber On Sat 16 May 2015 12:25:00 AM CEST, Eric Blake wrote: > Now that qbool is fixed, let's fix getting and setting a bool > value to a qdict member to also use C99 bool rather than int. > > I audited all callers to ensure that the changed return type > will not cause any changed semantics. > > Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Berto ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Use bool for QBool 2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake 2015-05-15 22:25 ` [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict Eric Blake @ 2015-05-28 19:54 ` Luiz Capitulino 2015-06-11 17:53 ` Luiz Capitulino 2015-06-16 14:53 ` Markus Armbruster 3 siblings, 1 reply; 13+ messages in thread From: Luiz Capitulino @ 2015-05-28 19:54 UTC (permalink / raw) To: Eric Blake Cc: kwolf, berto, mst, qemu-devel, armbru, mdroth, mreitz, afaerber On Fri, 15 May 2015 16:24:58 -0600 Eric Blake <eblake@redhat.com> wrote: > Passing around an 'int' for a QBool type is weird, when we already > use a C99 compiler and have a sane 'bool' that does just fine. > > I half-debated sending this through qemu-trivial, but think it > better belongs through the QMP tree. There turned out to be few > enough clients that I grouped it into two patches touching a number > of files each; but I'm also okay with splitting into finer-grained > patches that focus on fewer files at a time if that is desired. > > Eric Blake (2): > qobject: Use 'bool' for qbool > qobject: Use 'bool' inside qdict Applied to the qmp branch, thanks. > > block/qapi.c | 2 +- > block/quorum.c | 4 ++-- > block/vvfat.c | 4 ++-- > hmp.c | 40 ++++++++++++++++++++-------------------- > hw/pci/pcie_aer.c | 4 ++-- > include/qapi/qmp/qbool.h | 8 ++++---- > include/qapi/qmp/qdict.h | 4 ++-- > monitor.c | 12 ++++++------ > qapi/qmp-input-visitor.c | 2 +- > qapi/qmp-output-visitor.c | 2 +- > qobject/json-parser.c | 6 +++--- > qobject/qbool.c | 8 ++++---- > qobject/qdict.c | 8 ++++---- > qobject/qjson.c | 2 +- > qom/object.c | 4 ++-- > tests/check-qjson.c | 11 ++++++----- > tests/test-qmp-event.c | 4 ++-- > tests/test-qmp-output-visitor.c | 6 +++--- > util/qemu-option.c | 2 +- > 19 files changed, 67 insertions(+), 66 deletions(-) > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Use bool for QBool 2015-05-28 19:54 ` [Qemu-devel] [PATCH 0/2] Use bool for QBool Luiz Capitulino @ 2015-06-11 17:53 ` Luiz Capitulino 0 siblings, 0 replies; 13+ messages in thread From: Luiz Capitulino @ 2015-06-11 17:53 UTC (permalink / raw) To: Eric Blake Cc: kwolf, berto, mst, qemu-devel, armbru, mdroth, mreitz, afaerber On Thu, 28 May 2015 15:54:12 -0400 Luiz Capitulino <lcapitulino@redhat.com> wrote: > On Fri, 15 May 2015 16:24:58 -0600 > Eric Blake <eblake@redhat.com> wrote: > > > Passing around an 'int' for a QBool type is weird, when we already > > use a C99 compiler and have a sane 'bool' that does just fine. > > > > I half-debated sending this through qemu-trivial, but think it > > better belongs through the QMP tree. There turned out to be few > > enough clients that I grouped it into two patches touching a number > > of files each; but I'm also okay with splitting into finer-grained > > patches that focus on fewer files at a time if that is desired. > > > > Eric Blake (2): > > qobject: Use 'bool' for qbool > > qobject: Use 'bool' inside qdict > > Applied to the qmp branch, thanks. Unfortunately, I'm quite busy and won't have time to push this through my tree. Markus is going to pick up this series soon. Acked-by: Luiz Capitulino <lcapitulino@redhat.com> > > > > > block/qapi.c | 2 +- > > block/quorum.c | 4 ++-- > > block/vvfat.c | 4 ++-- > > hmp.c | 40 ++++++++++++++++++++-------------------- > > hw/pci/pcie_aer.c | 4 ++-- > > include/qapi/qmp/qbool.h | 8 ++++---- > > include/qapi/qmp/qdict.h | 4 ++-- > > monitor.c | 12 ++++++------ > > qapi/qmp-input-visitor.c | 2 +- > > qapi/qmp-output-visitor.c | 2 +- > > qobject/json-parser.c | 6 +++--- > > qobject/qbool.c | 8 ++++---- > > qobject/qdict.c | 8 ++++---- > > qobject/qjson.c | 2 +- > > qom/object.c | 4 ++-- > > tests/check-qjson.c | 11 ++++++----- > > tests/test-qmp-event.c | 4 ++-- > > tests/test-qmp-output-visitor.c | 6 +++--- > > util/qemu-option.c | 2 +- > > 19 files changed, 67 insertions(+), 66 deletions(-) > > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Use bool for QBool 2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake ` (2 preceding siblings ...) 2015-05-28 19:54 ` [Qemu-devel] [PATCH 0/2] Use bool for QBool Luiz Capitulino @ 2015-06-16 14:53 ` Markus Armbruster 3 siblings, 0 replies; 13+ messages in thread From: Markus Armbruster @ 2015-06-16 14:53 UTC (permalink / raw) To: Eric Blake Cc: kwolf, berto, mst, qemu-devel, mdroth, lcapitulino, mreitz, afaerber Eric Blake <eblake@redhat.com> writes: > Passing around an 'int' for a QBool type is weird, when we already > use a C99 compiler and have a sane 'bool' that does just fine. > > I half-debated sending this through qemu-trivial, but think it > better belongs through the QMP tree. There turned out to be few > enough clients that I grouped it into two patches touching a number > of files each; but I'm also okay with splitting into finer-grained > patches that focus on fewer files at a time if that is desired. Applied to my (badly named) qapi-next branch, thanks! ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-06-16 14:53 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake 2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake 2015-05-16 13:30 ` Andreas Färber 2015-05-16 17:13 ` Eric Blake 2015-05-18 6:42 ` Markus Armbruster 2015-05-19 12:59 ` Alberto Garcia 2015-06-12 5:35 ` Markus Armbruster 2015-06-12 15:38 ` Eric Blake 2015-05-15 22:25 ` [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict Eric Blake 2015-05-19 13:00 ` Alberto Garcia 2015-05-28 19:54 ` [Qemu-devel] [PATCH 0/2] Use bool for QBool Luiz Capitulino 2015-06-11 17:53 ` Luiz Capitulino 2015-06-16 14:53 ` Markus Armbruster
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).