qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH V3 2/5] qapi: add event helper functions


From: Eric Blake
Subject: Re: [Qemu-devel] [RFC PATCH V3 2/5] qapi: add event helper functions
Date: Mon, 24 Mar 2014 07:11:48 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 03/23/2014 06:53 PM, Wenchao Xia wrote:
> 于 2014/3/21 6:53, Eric Blake 写道:
>> On 03/18/2014 11:16 PM, Wenchao Xia wrote:
>>> This file hold some functions that do not need to be generated.
>> s/hold/holds/
>>

>>> +
>>> +typedef struct QMPEventFunctions {
>>> +    QMPEventFuncEmit emit;
>>> +} QMPEventFunctions;
>>> +
>>> +QMPEventFunctions qmp_event_functions;
>>> +
>>> +void qmp_event_set_func_emit(QMPEventFuncEmit emit)
>>> +{
>>> +    qmp_event_functions.emit = emit;
>>> +}
>>> +
>>> +QMPEventFuncEmit qmp_event_get_func_emit(void)
>>> +{
>>> +    return qmp_event_functions.emit;
>>> +}
>> Is this struct a bit overkill, or do you extend it to include other
>> fields later?
>   No other fields will be added in this series, it allow different emit
> function hooked.
> Do you mean remove it and put it into generated qapi-event.c?

Keeping accessor functions is still a bit nicer than directly making a
global variable; but my point is that your accessors can just directly
access a static variable instead of wrapping things in a pointless struct:

static QMPEventFuncEmit qmp_emit;
void qmp_event_set_func_emit(QMPEventFuncEmit emit)
{
    qmp_emit = emit;
}
QMPEventFuncEmit qmp_event_get_func_emit(void)
{
    return qmp_emit;
}

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]