qdev: wrap default property value in an union
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 <marcandre.lureau@redhat.com> Message-Id: <20170607163635.17635-17-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
85bbd1e7a4
commit
76318657a8
@ -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 = {
|
||||
|
@ -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;
|
||||
|
@ -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-"
|
||||
|
Loading…
Reference in New Issue
Block a user