[libvirt] [PATCH] util: Fix build with clang

When compiling with clang on Linux, it complains that "passing an object that undergoes default argument promotion to 'va_start' has undefined behavior". That is true according to the C standard, although I couldn't find any mention about enum->int promotion (even though it's a sensible one). The only fix I came up with was changing the layer parameter to int so that it does not undergo any default argument promotion. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- Even though this is a build-breaker, I don't see anyone (or CI) complaining about it, and the fix doesn't lok that nice, so... src/util/virfirewall.c | 4 ++-- src/util/virfirewall.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 3f976186a671..da4602aa422b 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -417,7 +417,7 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, */ virFirewallRulePtr virFirewallAddRule(virFirewallPtr firewall, - virFirewallLayer layer, + int layer, ...) { virFirewallRulePtr rule; @@ -452,7 +452,7 @@ virFirewallAddRule(virFirewallPtr firewall, * Returns the new rule */ virFirewallRulePtr virFirewallAddRuleFull(virFirewallPtr firewall, - virFirewallLayer layer, + int layer, bool ignoreErrors, virFirewallQueryCallback cb, void *opaque, diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h index dbf397537fa8..51608b648633 100644 --- a/src/util/virfirewall.h +++ b/src/util/virfirewall.h @@ -45,7 +45,7 @@ virFirewallPtr virFirewallNew(void); void virFirewallFree(virFirewallPtr firewall); virFirewallRulePtr virFirewallAddRule(virFirewallPtr firewall, - virFirewallLayer layer, + int layer, ...) ATTRIBUTE_SENTINEL; @@ -54,7 +54,7 @@ typedef int (*virFirewallQueryCallback)(virFirewallPtr firewall, void *opaque); virFirewallRulePtr virFirewallAddRuleFull(virFirewallPtr firewall, - virFirewallLayer layer, + int layer, bool ignoreErrors, virFirewallQueryCallback cb, void *opaque, -- 2.11.0

On Fri, Dec 09, 2016 at 11:52:43AM +0100, Martin Kletzander wrote:
When compiling with clang on Linux, it complains that "passing an object that undergoes default argument promotion to 'va_start' has undefined behavior". That is true according to the C standard, although I couldn't find any mention about enum->int promotion (even though it's a sensible one). The only fix I came up with was changing the layer parameter to int so that it does not undergo any default argument promotion.
Can we not just cast 'layer' to an int in the va_start call ? Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

On Fri, Dec 09, 2016 at 11:18:32AM +0000, Daniel P. Berrange wrote:
On Fri, Dec 09, 2016 at 11:52:43AM +0100, Martin Kletzander wrote:
When compiling with clang on Linux, it complains that "passing an object that undergoes default argument promotion to 'va_start' has undefined behavior". That is true according to the C standard, although I couldn't find any mention about enum->int promotion (even though it's a sensible one). The only fix I came up with was changing the layer parameter to int so that it does not undergo any default argument promotion.
Can we not just cast 'layer' to an int in the va_start call ?
That also fails to compile. Jan
participants (3)
-
Daniel P. Berrange
-
Ján Tomko
-
Martin Kletzander