From: Andrew Cooper Date: Thu, 28 Apr 2016 12:04:51 +0000 (+0100) Subject: Introduce snprintf() and give vsnprintf() an appropriate __printf() attribute X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e2f1d2cc25bede1a2cc14934f53886d2b1e7294b;p=people%2Froyger%2Fxen-test-framework.git Introduce snprintf() and give vsnprintf() an appropriate __printf() attribute Signed-off-by: Andrew Cooper --- diff --git a/include/xtf/libc.h b/include/xtf/libc.h index 65ea6c8..cf0aaf4 100644 --- a/include/xtf/libc.h +++ b/include/xtf/libc.h @@ -2,6 +2,7 @@ #define XTF_LIBC_H #include +#include /* * Local declaration of bits of libc @@ -24,7 +25,21 @@ void *memset(void *s, int c, size_t n); void *memcpy(void *dst, const void *src, size_t n); int memcmp(const void *s1, const void *s2, size_t n); -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +int __printf(3, 0) + vsnprintf(char *buf, size_t size, const char *fmt, va_list args); + +static inline int __printf(3, 4) + snprintf(char *buf, size_t size, const char *fmt, ...) +{ + va_list args; + int rc; + + va_start(args, fmt); + rc = vsnprintf(buf, size, fmt, args); + va_end(args); + + return rc; +} #endif /* XTF_LIBC_H */