[libvirt] [PATCH 1/2] util: Turn virFirewallAddRule() into a macro

Martin Kletzander mkletzan at redhat.com
Tue Jan 3 12:46:40 UTC 2017


On Mon, Jan 02, 2017 at 07:15:30PM +0100, Andrea Bolognani wrote:
>Clang 3.9 refuses to compile the existing code with the
>following error:
>
>  util/virfirewall.c:425:20: error: passing an object that undergoes
>                             default argument promotion to 'va_start'
>                             has undefined behavior [-Werror,-Wvarargs]
>      va_start(args, layer);
>                     ^
>  util/virfirewall.c:420:37: note: parameter of type 'virFirewallLayer'
>                             is declared here
>                     virFirewallLayer layer,
>                                      ^
>
>This happens because 'layer' is of type virFirewallLayer, which
>is an enum type and not a standard type such as eg. void* or int.
>
>To solve the issue, turn virFirewallAddRule() from a very thin
>wrapper around virFirewallAddRuleFullV() to a macro that expands
>to a call to virFirewallAddRuleFull() - itself a very thin wrapper
>around the aforementioned virFirewallAddRuleFullV() - with no loss
>of functionality or type safety.
>---
>This only seems to be required on very specific combinations
>of Clang and host OS, eg. I need it on Clang 3.9 / Fedora
>rawhide but not on Clang 3.8 or 4.0 / Debian sid.
>

We sent various patches for this (me, Jan and maybe other people as
well).  I never realized it's not a problem with different versions of
clang.  I would say it's not a problem for us to solve it in this case,
however, as I wrote in my solution, it works, but it's undefined from
the specification point of view.  Can it work just because
virFirewallAddRule() gets optimized into inline function?  it shouldn't
be, though...  I don't know.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170103/f70860e7/attachment-0001.sig>


More information about the libvir-list mailing list