aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/core/qdev-properties.c6
-rw-r--r--include/hw/qdev-core.h4
-rw-r--r--include/hw/qdev-properties.h8
3 files changed, 10 insertions, 8 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index c5e028a45e..f3f682c611 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 9523339762..784971b8d8 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 05603805cb..34524d0bfe 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-"