From patchwork Fri Jun 9 13:47:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 773950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wkkL52Mxhz9sND for ; Fri, 9 Jun 2017 23:54:21 +1000 (AEST) Received: from localhost ([::1]:54805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJKMl-0006vb-0J for incoming@patchwork.ozlabs.org; Fri, 09 Jun 2017 09:54:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJKGI-0000fK-8U for qemu-devel@nongnu.org; Fri, 09 Jun 2017 09:47:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJKGG-0003Yr-4I for qemu-devel@nongnu.org; Fri, 09 Jun 2017 09:47:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33610) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJKGF-0003Xh-RJ for qemu-devel@nongnu.org; Fri, 09 Jun 2017 09:47:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1DF485541 for ; Fri, 9 Jun 2017 13:47:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D1DF485541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D1DF485541 Received: from blackfin.pond.sub.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FE108D76C; Fri, 9 Jun 2017 13:47:34 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BAB2F11385FC; Fri, 9 Jun 2017 15:47:25 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 15:47:00 +0200 Message-Id: <1497016045-6009-17-git-send-email-armbru@redhat.com> In-Reply-To: <1497016045-6009-1-git-send-email-armbru@redhat.com> References: <1497016045-6009-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 09 Jun 2017 13:47:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/41] qdev: wrap default property value in an union X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Wrap the Property default value (an int64_t) in a union, to prepare for the next patch adding a uint64_t. Signed-off-by: Marc-André Lureau Message-Id: <20170607163635.17635-17-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- hw/core/qdev-properties.c | 6 +++--- include/hw/qdev-core.h | 4 +++- include/hw/qdev-properties.h | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index c5e028a..f3f682c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque, static void set_default_value_enum(Object *obj, const Property *prop) { - object_property_set_str(obj, prop->info->enum_table[prop->defval], + object_property_set_str(obj, prop->info->enum_table[prop->defval.i], prop->name, &error_abort); } @@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name, static void set_default_value_bool(Object *obj, const Property *prop) { - object_property_set_bool(obj, prop->defval, prop->name, &error_abort); + object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort); } PropertyInfo qdev_prop_bit = { @@ -261,7 +261,7 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, static void set_default_value_int(Object *obj, const Property *prop) { - object_property_set_int(obj, prop->defval, prop->name, &error_abort); + object_property_set_int(obj, prop->defval.i, prop->name, &error_abort); } PropertyInfo qdev_prop_uint8 = { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 9523339..784971b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -226,7 +226,9 @@ struct Property { PropertyInfo *info; ptrdiff_t offset; uint8_t bitnr; - int64_t defval; + union { + int64_t i; + } defval; int arrayoffset; PropertyInfo *arrayinfo; int arrayfieldsize; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 0560380..34524d0 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -42,7 +42,7 @@ extern PropertyInfo qdev_prop_arraylen; .info = &(_prop), \ .offset = offsetof(_state, _field) \ + type_check(_type,typeof_field(_state, _field)), \ - .defval = (_type)_defval, \ + .defval.i = (_type)_defval, \ } #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ .name = (_name), \ @@ -50,7 +50,7 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr = (_bit), \ .offset = offsetof(_state, _field) \ + type_check(uint32_t,typeof_field(_state, _field)), \ - .defval = (bool)_defval, \ + .defval.i = (bool)_defval, \ } #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \ .name = (_name), \ @@ -58,7 +58,7 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr = (_bit), \ .offset = offsetof(_state, _field) \ + type_check(uint64_t, typeof_field(_state, _field)), \ - .defval = (bool)_defval, \ + .defval.i = (bool)_defval, \ } #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \ @@ -66,7 +66,7 @@ extern PropertyInfo qdev_prop_arraylen; .info = &(qdev_prop_bool), \ .offset = offsetof(_state, _field) \ + type_check(bool, typeof_field(_state, _field)), \ - .defval = (bool)_defval, \ + .defval.i = (bool)_defval, \ } #define PROP_ARRAY_LEN_PREFIX "len-"