From patchwork Sat Oct 17 13:36:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 36307 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 91906B7B77 for ; Sun, 18 Oct 2009 00:48:18 +1100 (EST) Received: from localhost ([127.0.0.1]:41324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mz9dn-0002LY-92 for incoming@patchwork.ozlabs.org; Sat, 17 Oct 2009 09:48:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mz9SN-0005or-LM for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mz9SH-0005ks-1F for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:25 -0400 Received: from [199.232.76.173] (port=58965 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mz9SG-0005ka-Ak for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:20 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:39383) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mz9SF-0000OY-Pj for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:20 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e31.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9HDTfgZ026505 for ; Sat, 17 Oct 2009 07:29:41 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9HDaEA7195780 for ; Sat, 17 Oct 2009 07:36:14 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n9HDaEYE021586 for ; Sat, 17 Oct 2009 07:36:14 -0600 Received: from localhost.localdomain (sig-9-65-54-101.mts.ibm.com [9.65.54.101]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n9HDaBJH021369; Sat, 17 Oct 2009 07:36:14 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Sat, 17 Oct 2009 08:36:07 -0500 Message-Id: <1255786571-3528-8-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> References: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH 07/11] qjson: Use QBool for true/false keywords X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Instead of parsing true/false as QInt, parse them as QBool and update the test suite accordingly. Signed-off-by: Anthony Liguori --- Makefile | 2 +- check-qjson.c | 19 ++++++++++--------- qjson.c | 5 +++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 095d2ce..fe6c9bf 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ check-qstring: check-qstring.o qstring.o qemu-malloc.o check-qdict: check-qdict.o qdict.o qint.o qstring.o qemu-malloc.o check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o -check-qjson: check-qjson.o qjson.o qstring.o qint.o qdict.o qlist.o qfloat.o qemu-malloc.o +check-qjson: check-qjson.o qjson.o qstring.o qint.o qdict.o qlist.o qfloat.o qbool.o qemu-malloc.o clean: # avoid old build problems by removing potentially incorrect old files diff --git a/check-qjson.c b/check-qjson.c index 0f661b9..32aa33c 100644 --- a/check-qjson.c +++ b/check-qjson.c @@ -15,6 +15,7 @@ #include "qdict.h" #include "qlist.h" #include "qfloat.h" +#include "qbool.h" #include "qjson.h" #include "qemu-common.h" @@ -259,28 +260,28 @@ END_TEST START_TEST(keyword_literal) { QObject *obj; - QInt *qint; + QBool *qbool; size_t length = 0; obj = qobject_from_json("true", &length); fail_unless(obj != NULL); - fail_unless(qobject_type(obj) == QTYPE_QINT); + fail_unless(qobject_type(obj) == QTYPE_QBOOL); fail_unless(length == 4); - qint = qobject_to_qint(obj); - fail_unless(qint_get_int(qint) != 0); + qbool = qobject_to_qbool(obj); + fail_unless(qbool_get_int(qbool) != 0); - QDECREF(qint); + QDECREF(qbool); obj = qobject_from_json("false", &length); fail_unless(obj != NULL); - fail_unless(qobject_type(obj) == QTYPE_QINT); + fail_unless(qobject_type(obj) == QTYPE_QBOOL); fail_unless(length == 5); - qint = qobject_to_qint(obj); - fail_unless(qint_get_int(qint) == 0); + qbool = qobject_to_qbool(obj); + fail_unless(qbool_get_int(qbool) == 0); - QDECREF(qint); + QDECREF(qbool); } END_TEST diff --git a/qjson.c b/qjson.c index 64cecc6..ce2c942 100644 --- a/qjson.c +++ b/qjson.c @@ -17,6 +17,7 @@ #include "qdict.h" #include "qlist.h" #include "qfloat.h" +#include "qbool.h" #include "qjson.h" typedef struct JSONParserContext @@ -627,9 +628,9 @@ static QObject *parse_keyword(JSONParserContext *ctxt, const char *data, size_t } if (strcmp(qstring_get_str(str), "true") == 0) { - obj = QOBJECT(qint_from_int(1)); + obj = QOBJECT(qbool_from_int(1)); } else if (strcmp(qstring_get_str(str), "false") == 0) { - obj = QOBJECT(qint_from_int(0)); + obj = QOBJECT(qbool_from_int(0)); } if (obj) {