Re: [PATCH 4/5] util: XML: Introduce automatic reset of XPath's current node

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

 



On 2/27/19 3:27 AM, Peter Krempa wrote:

>>> + * node pointer is reset to the original value when this macro was used.
>>> + */
>>> +# define VIR_XPATH_NODE_AUTORESTORE(ctxt) \
>>> +    VIR_AUTOCLEAN(virXPathContextNodeSave) ctxt ## CtxtSave = {(ctxt), (ctxt)->node}
>>
>> Worth using C99 syntax as in { .ctxt = (ctxt), .node = (ctxt)->node, } ?
> 
> It would require renaming the argument of the macro as it would be
> replaced otherwise. Interrestingly in most cases it would actually work
> as in most cases the macro is used with 'ctxt'.

And hence why it's a good idea to use macro parameter names which can't
conflict with normal cods, such as:

#define VIR_XPATH_NODE_AUTORESTORE(_ctxt) \
    VIR_AUTOCLEAN(virXPathContextNodeSave) _ctxt##CtxtSave = { \
        .ctxt = (_ctxt), .node = (_ctxt)->node, }

But I'll leave it up to you to decide whether it makes sense to worry
about C99 initializers.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux