[PATCH] virFirewallAddRule: fix build with clang

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

 



clang complains:
util/virfirewall.c:425:20: error: passing an object that undergoes
default argument promotion to 'va_start' has undefined behavior
[-Werror,-Wvarargs]
    __builtin_va_start(args, layer);

Introduce a macro wrapper that puts a NULL pointer after the enum
argument.
---
Previous attempts exchanged the arguments:
https://www.redhat.com/archives/libvir-list/2016-June/msg02173.html

or changed the type to int:
https://www.redhat.com/archives/libvir-list/2016-December/msg00379.html

 src/libvirt_private.syms |  2 +-
 src/util/virfirewall.c   |  9 +++++----
 src/util/virfirewall.h   | 11 ++++++++---
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 867acdb..4c92dba 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1616,8 +1616,8 @@ virFindFileInPath;
 
 
 # util/virfirewall.h
-virFirewallAddRule;
 virFirewallAddRuleFull;
+virFirewallAddRuleInt;
 virFirewallApply;
 virFirewallFree;
 virFirewallNew;
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 3f97618..c71a274 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -416,13 +416,14 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
  * Returns the new rule
  */
 virFirewallRulePtr
-virFirewallAddRule(virFirewallPtr firewall,
-                   virFirewallLayer layer,
-                   ...)
+virFirewallAddRuleInt(virFirewallPtr firewall,
+                      virFirewallLayer layer,
+                      void *null,
+                      ...)
 {
     virFirewallRulePtr rule;
     va_list args;
-    va_start(args, layer);
+    va_start(args, null);
     rule = virFirewallAddRuleFullV(firewall, layer, false, NULL, NULL, args);
     va_end(args);
     return rule;
diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h
index dbf3975..f28a421 100644
--- a/src/util/virfirewall.h
+++ b/src/util/virfirewall.h
@@ -44,11 +44,16 @@ virFirewallPtr virFirewallNew(void);
 
 void virFirewallFree(virFirewallPtr firewall);
 
-virFirewallRulePtr virFirewallAddRule(virFirewallPtr firewall,
-                                      virFirewallLayer layer,
-                                      ...)
+virFirewallRulePtr virFirewallAddRuleInt(virFirewallPtr firewall,
+                                         virFirewallLayer layer,
+                                         void *null,
+                                         ...)
     ATTRIBUTE_SENTINEL;
 
+/* work around passing an enum to va_start */
+# define virFirewallAddRule(firewall, layer, ...) \
+         virFirewallAddRuleInt(firewall, layer, NULL, __VA_ARGS__)
+
 typedef int (*virFirewallQueryCallback)(virFirewallPtr firewall,
                                         const char *const *lines,
                                         void *opaque);
-- 
2.7.3

--
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