From patchwork Fri May 8 13:34:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 470045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 32F04140295 for ; Fri, 8 May 2015 23:35:02 +1000 (AEST) Received: from localhost ([::1]:55835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiQe-0001w2-Cy for incoming@patchwork.ozlabs.org; Fri, 08 May 2015 09:35:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiPz-0000kv-JQ for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqiPy-0002VF-P5 for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiPy-0002V0-EY for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t48DYGcc004828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 May 2015 09:34:16 -0400 Received: from localhost (ovpn-113-30.phx2.redhat.com [10.3.113.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t48DYGte023310; Fri, 8 May 2015 09:34:16 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 8 May 2015 09:34:04 -0400 Message-Id: <1431092051-31046-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com> References: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 03/10] qobject: Clean up around qtype_code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster 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 Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- 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 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(); } }