From e39ec70ef030fa4e7c2963e6bbb059a42490905d Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 14 Apr 2015 20:21:54 +0900 Subject: [PATCH] Prevent compiler warnings with 9.0 PG_PRINTF_ATTRIBUTE was introduced with 9.1. --- log.h | 6 ++++++ strutil.c | 6 ++++++ strutil.h | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/log.h b/log.h index 6faebf07..c73cc23a 100644 --- a/log.h +++ b/log.h @@ -25,9 +25,15 @@ #define REPMGR_SYSLOG 1 #define REPMGR_STDERR 2 +#if (PG_VERSION_NUM >= 90100) void stderr_log_with_level(const char *level_name, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); +#else +void +stderr_log_with_level(const char *level_name, int level, const char *fmt,...) +__attribute__((format(printf, 3, 4))); +#endif /* Standard error logging */ #define stderr_log_debug(...) stderr_log_with_level("DEBUG", LOG_DEBUG, __VA_ARGS__) diff --git a/strutil.c b/strutil.c index 018ec3b9..235a9c72 100644 --- a/strutil.c +++ b/strutil.c @@ -25,9 +25,15 @@ #include "log.h" #include "strutil.h" +#if (PG_VERSION_NUM >= 90100) static int xvsnprintf(char *str, size_t size, const char *format, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); +#else +static int +xvsnprintf(char *str, size_t size, const char *format, va_list ap) +__attribute__((format(printf, 3, 0))); +#endif static int xvsnprintf(char *str, size_t size, const char *format, va_list ap) diff --git a/strutil.h b/strutil.h index 142f588b..3e53983e 100644 --- a/strutil.h +++ b/strutil.h @@ -31,6 +31,7 @@ #define MAXCONNINFO 1024 +#if (PG_VERSION_NUM >= 90100) extern int xsnprintf(char *str, size_t size, const char *format,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); @@ -42,5 +43,18 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); extern int maxlen_snprintf(char *str, const char *format,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); +#else +extern int +xsnprintf(char *str, size_t size, const char *format,...) +__attribute__((format(printf, 3, 4))); + +extern int +sqlquery_snprintf(char *str, const char *format,...) +__attribute__((format(printf, 2, 3))); + +extern int +maxlen_snprintf(char *str, const char *format,...) +__attribute__((format(printf, 2, 3))); +#endif #endif /* _STRUTIL_H_ */