On 10/04/2012 04:13 PM, Anthony Liguori wrote:
>>
>> +void address_space_init_dispatch(AddressSpace *as)
>> +{
>> + AddressSpaceDispatch *d = g_new(AddressSpaceDispatch, 1);
>> +
>> + d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0
>> };
>> + d->listener = (MemoryListener) {
>> + MEMORY_LISTENER_DEFAULT_OPS,
>> + .begin = mem_begin,
>> + .region_add = mem_add,
>> + .region_nop = mem_add,
>> + .priority = 0,
>> + };
>
> I see you've become fond of this extension :-)
It's not an extension.
> I'd personally avoid it... You're typing more than you need to.
Don't see why, it seems to me to be a direct way of specifying what you
want. You can read it literally as "d->phys_map is assigned a
PhysPageEntry structure with ptr = this and is_leaf = that.
The alternatives are:
memset(&d->phys_map, 0, sizeof(d->phys_map);
d->phys_map.ptr = PHYS_MAP_NODE_NIL;
d->phys_map.is_leaf = 0;
or
PhysPageEntry tmp = { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0 };
d->phys_map = tmp;
I find both of these less appealing than the original.
--
error compiling committee.c: too many arguments to function