mirror of https://gitee.com/openkylin/libvirt.git
Add sentinel attribute for NULL terminated arg lists
* 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
This commit is contained in:
parent
4fbad2e049
commit
649bcd72fe
|
@ -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"),
|
||||
|
|
|
@ -92,6 +92,17 @@
|
|||
#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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue