]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add sentinel attribute for NULL terminated arg lists
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Nov 2009 09:39:13 +0000 (10:39 +0100)
committerDaniel Veillard <veillard@redhat.com>
Fri, 6 Nov 2009 09:39:13 +0000 (10:39 +0100)
* src/internal.h (ATTRIBUTE_SENTINEL): New, it's a ggc feature and
  protected as such
* src/util/buf.c (virBufferStrcat): Use it.
* src/util/ebtables.c (ebtablesAddRemoveRule): Use it.
* src/util/iptables.c (iptableAddRemoveRule: Use it.
* src/util/qparams.h (new_qparam_set, append_qparams): Use it.
* docs/apibuild.py: avoid breaking the API generator with that new
  internal keyword macro

docs/apibuild.py
src/internal.h
src/util/buf.h
src/util/ebtables.c
src/util/iptables.c
src/util/qparams.h

index c5257f38136a2970167ed761ecbd235884e9c4df..e233c8b43b61f6f783ac50d5ad505510cbd0e305 100755 (executable)
@@ -26,6 +26,7 @@ included_files = {
 
 ignored_words = {
   "ATTRIBUTE_UNUSED": (0, "macro keyword"),
+  "ATTRIBUTE_SENTINEL": (0, "macro keyword"),
   "VIR_DEPRECATED": (0, "macro keyword"),
   "WINAPI": (0, "Windows keyword"),
   "__declspec": (3, "Windows keyword"),
index bd1cfe680b7a9da40a1c34dfdb2e4af3180daeba..09c19eae6a93e38a3bfbd74d43ba9a9f1f83a9c9 100644 (file)
 #define ATTRIBUTE_UNUSED __attribute__((__unused__))
 #endif
 
+/**
+ * ATTRIBUTE_SENTINEL:
+ *
+ * Macro to check for NULL-terminated varargs lists
+ */
+#ifndef ATTRIBUTE_SENTINEL
+#if __GNUC_PREREQ (4, 0)
+#define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
+#endif
+#endif
+
 /**
  * ATTRIBUTE_FMT_PRINTF
  *
index 7d31cb2ac23d6a3213eb835e9c942aa060e4cb1b..94ee8a3d1029add3689d691f5fb18a600a9186a7 100644 (file)
@@ -41,7 +41,8 @@ void virBufferAdd(const virBufferPtr buf, const char *str, int len);
 void virBufferAddChar(const virBufferPtr buf, char c);
 void virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
   ATTRIBUTE_FMT_PRINTF(2, 3);
-void virBufferStrcat(const virBufferPtr buf, ...);
+void virBufferStrcat(const virBufferPtr buf, ...)
+  ATTRIBUTE_SENTINEL;
 void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
 void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
 
index 60427d7099fbaec90bb980d382ca3494f0978a33..20f33425be934a783e3ce5fc5accb41a4c8c8a2a 100644 (file)
@@ -175,7 +175,7 @@ ebtRulesNew(const char *table,
     return NULL;
 }
 
-static int
+static int ATTRIBUTE_SENTINEL
 ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
 {
     va_list args;
index 45628009ceeaacf0ded39e7213681b15c77dd24c..284f3c0f02dd69cdfebe645bacfbf64645ac1731 100644 (file)
@@ -382,7 +382,7 @@ iptRulesNew(const char *table,
     return NULL;
 }
 
-static int
+static int ATTRIBUTE_SENTINEL
 iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
 {
     va_list args;
index 1a92048196d112b46d160453d824260f01d4b57f..a2f5aa2e1a25fb412c7804c0a9e779bedbba4e2f 100644 (file)
@@ -38,10 +38,12 @@ struct qparam_set {
 };
 
 /* New parameter set. */
-extern struct qparam_set *new_qparam_set (int init_alloc, ...);
+extern struct qparam_set *new_qparam_set (int init_alloc, ...)
+    ATTRIBUTE_SENTINEL;
 
 /* Appending parameters. */
-extern int append_qparams (struct qparam_set *ps, ...);
+extern int append_qparams (struct qparam_set *ps, ...)
+    ATTRIBUTE_SENTINEL;
 extern int append_qparam (struct qparam_set *ps,
                           const char *name, const char *value);