From f5a70d968c81938584ce032ae692e2d972f3a220 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 4 Dec 2025 14:58:07 +0100 Subject: [PATCH] include: fix warning on XNFvasprintf() prototype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ../os/xprintf.c: In function ‘XNFvasprintf’: > ../os/xprintf.c:84:5: warning: function ‘XNFvasprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] > 84 | int size = vasprintf(ret, format, va); > | ^~~ Signed-off-by: Enrico Weigelt, metux IT consult --- include/Xprintf.h | 4 +++- include/os.h | 9 +++++++++ os/audit_priv.h | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/Xprintf.h b/include/Xprintf.h index aeedd2010c..382e24f63f 100644 --- a/include/Xprintf.h +++ b/include/Xprintf.h @@ -28,6 +28,8 @@ #include #include +#include "os.h" + #ifndef _X_RESTRICT_KYWD #if defined(restrict) /* assume autoconf set it correctly */ || \ (defined(__STDC__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ @@ -53,6 +55,6 @@ XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD fmt, ...) _X_ATTRIBUTE_PRINTF(2, 3); extern _X_EXPORT int XNFvasprintf(char **ret, const char *_X_RESTRICT_KYWD fmt, va_list va) -_X_ATTRIBUTE_PRINTF(2, 0); +_X_ATTRIBUTE_VPRINTF(2, 0); #endif /* XPRINTF_H */ diff --git a/include/os.h b/include/os.h index 6238f9b362..1108b2535f 100644 --- a/include/os.h +++ b/include/os.h @@ -69,6 +69,15 @@ SOFTWARE. #define _X_ATTRIBUTE_NONNULL_ARG(...) __attribute__((nonnull(__VA_ARGS__))) #endif +#ifndef _X_ATTRIBUTE_VPRINTF +# if defined(__GNUC__) && (__GNUC__ >= 2) +# define _X_ATTRIBUTE_VPRINTF(fmt, firstarg) \ + __attribute__((__format__(gnu_printf, fmt, firstarg))) +# else +# define _X_ATTRIBUTE_VPRINTF(fmt, firstarg) _X_ATTRIBUTE_PRINTF(fmt,firstarg) +# endif +#endif + #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1 #define SCREEN_SAVER_FORCER 2 diff --git a/os/audit_priv.h b/os/audit_priv.h index 205109489e..bb1f087ab5 100644 --- a/os/audit_priv.h +++ b/os/audit_priv.h @@ -8,11 +8,13 @@ #include #include +#include "include/os.h" + extern int auditTrailLevel; void FreeAuditTimer(void); void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2); -void VAuditF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1, 0); +void VAuditF(const char *f, va_list args) _X_ATTRIBUTE_VPRINTF(1, 0); #endif /* _XSERVER_OS_AUDIT_H */