From d528227d4c30869dce6fa81124d12b39bcb987cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 7 Jun 2017 20:36:10 +0400 Subject: apic-common: make "id" property a uint32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The getter and setter of TYPE_APIC_COMMON property "id" are apic_common_get_id() and apic_common_set_id(). apic_common_get_id() reads either APICCommonState member uint32_t initial_apic_id or uint8_t id into an int64_t local variable. It then passes this variable to visit_type_int(). apic_common_set_id() uses visit_type_int() to read the value into a local variable, which it then assigns both to initial_apic_id and id. While the state backing the property is two unsigned members, 8 and 32 bits wide, the actual visitor is 64 bits signed. Change getter and setter to use visit_type_uint32(). Then everything's uint32_t, except for @id. Suggested-by: Markus Armbruster Signed-off-by: Marc-André Lureau Message-Id: <20170607163635.17635-19-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- hw/intc/apic_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 1ef56f8..e1ac330 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -450,10 +450,10 @@ static void apic_common_get_id(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { APICCommonState *s = APIC_COMMON(obj); - int64_t value; + uint32_t value; value = s->apicbase & MSR_IA32_APICBASE_EXTD ? s->initial_apic_id : s->id; - visit_type_int(v, name, &value, errp); + visit_type_uint32(v, name, &value, errp); } static void apic_common_set_id(Object *obj, Visitor *v, const char *name, @@ -462,14 +462,14 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, APICCommonState *s = APIC_COMMON(obj); DeviceState *dev = DEVICE(obj); Error *local_err = NULL; - int64_t value; + uint32_t value; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_int(v, name, &value, &local_err); + visit_type_uint32(v, name, &value, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -484,7 +484,7 @@ static void apic_common_initfn(Object *obj) APICCommonState *s = APIC_COMMON(obj); s->id = s->initial_apic_id = -1; - object_property_add(obj, "id", "int", + object_property_add(obj, "id", "uint32", apic_common_get_id, apic_common_set_id, NULL, NULL, NULL); } -- cgit v1.1