Use a macro variable PG_PRINTF_ATTRIBUTE for the style used for checking printf type functions.
The style is set to "printf" for backwards compatibility everywhere except on Windows, where it is set to "gnu_printf", which eliminates hundreds of false error messages from modern versions of gcc arising from %m and %ll{d,u} formats.
This commit is contained in:
parent
39850c7fdb
commit
c02d5b7c27
@ -33,7 +33,7 @@ static char *printTypmod(const char *typname, int32 typmod, Oid typmodout);
|
||||
static char *
|
||||
psnprintf(size_t len, const char *fmt,...)
|
||||
/* This lets gcc check the format string for consistency. */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
|
||||
/*
|
||||
|
@ -115,7 +115,7 @@ static void
|
||||
write_stderr(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
static void *pg_malloc(size_t size);
|
||||
static char *xstrdup(const char *s);
|
||||
static void do_advice(void);
|
||||
|
@ -152,7 +152,7 @@ typedef struct _restoreOptions
|
||||
|
||||
extern void
|
||||
exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
|
||||
|
||||
/* Lets the archive know we have a DB connection to shutdown if it dies */
|
||||
@ -207,7 +207,7 @@ extern int archputs(const char *s, Archive *AH);
|
||||
extern int
|
||||
archprintf(Archive *AH, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
#define appendStringLiteralAH(buf,str,AH) \
|
||||
appendStringLiteral(buf, str, (AH)->encoding, (AH)->std_strings)
|
||||
|
@ -328,9 +328,9 @@ typedef struct _tocEntry
|
||||
/* Used everywhere */
|
||||
extern const char *progname;
|
||||
|
||||
extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
|
||||
extern void warn_or_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
|
||||
extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(printf, 2, 3)));
|
||||
extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
extern void warn_or_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
extern void WriteTOC(ArchiveHandle *AH);
|
||||
extern void ReadTOC(ArchiveHandle *AH);
|
||||
@ -378,8 +378,8 @@ extern int ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *
|
||||
extern void DropBlobIfExists(ArchiveHandle *AH, Oid oid);
|
||||
|
||||
int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH);
|
||||
int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf, 2, 3)));
|
||||
int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf, 3, 4)));
|
||||
void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@ extern bool setQFout(const char *fname);
|
||||
extern void
|
||||
psql_error(const char *fmt,...)
|
||||
/* This lets gcc check the format string for consistency. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern void NoticeProcessor(void *arg, const char *message);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
static void
|
||||
print_lo_result(const char *fmt,...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
static void
|
||||
print_lo_result(const char *fmt,...)
|
||||
|
@ -773,7 +773,7 @@ typedef NameData *Name;
|
||||
extern int
|
||||
snprintf(char *str, size_t count, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_VSNPRINTF
|
||||
|
@ -95,7 +95,7 @@ extern void resetStringInfo(StringInfo str);
|
||||
extern void
|
||||
appendStringInfo(StringInfo str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
/*------------------------
|
||||
* appendStringInfoVA
|
||||
|
@ -154,6 +154,21 @@
|
||||
*/
|
||||
#define MAX_RANDOM_VALUE (0x7FFFFFFF)
|
||||
|
||||
/*
|
||||
* Set the format style used by gcc to check printf type functions. We really
|
||||
* want the "gnu_printf" style set, which includes what glibc uses, such
|
||||
* as %m for error strings and %lld for 64 bit long longs. But not all gcc
|
||||
* compilers are known to support it, so we just use "printf" which all
|
||||
* gcc versions alive are known to support, except on Windows where
|
||||
* using "gnu_printf" style makes a dramatic difference. Maybe someday
|
||||
* we'll have a configure test for this, if we ever discover use of more
|
||||
* variants to be necessary.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define PG_PRINTF_ATTRIBUTE gnu_printf
|
||||
#else
|
||||
#define PG_PRINTF_ATTRIBUTE printf
|
||||
#endif
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------------
|
||||
|
@ -197,20 +197,20 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||
extern int
|
||||
pg_snprintf(char *str, size_t count, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
extern int
|
||||
pg_sprintf(char *str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
extern int pg_vfprintf(FILE *stream, const char *fmt, va_list args);
|
||||
extern int
|
||||
pg_fprintf(FILE *stream, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
extern int
|
||||
pg_printf(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
/*
|
||||
* The GCC-specific code below prevents the __attribute__(... 'printf')
|
||||
|
@ -124,53 +124,53 @@ extern int
|
||||
errmsg(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errmsg_internal(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 4)))
|
||||
__attribute__((format(printf, 2, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
||||
|
||||
extern int
|
||||
errdetail(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errdetail_log(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 4)))
|
||||
__attribute__((format(printf, 2, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
||||
|
||||
extern int
|
||||
errhint(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errcontext(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int errhidestmt(bool hide_stmt);
|
||||
|
||||
@ -197,7 +197,7 @@ extern void
|
||||
elog_finish(int elevel, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
|
||||
/* Support for constructing error strings separately from ereport() calls */
|
||||
@ -207,7 +207,7 @@ extern char *
|
||||
format_elog_string(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
|
||||
/* Support for attaching context information to error reports */
|
||||
@ -366,6 +366,6 @@ extern void
|
||||
write_stderr(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
#endif /* ELOG_H */
|
||||
|
@ -76,7 +76,7 @@ extern char *mm_strdup(const char *);
|
||||
extern void
|
||||
mmerror(int, enum errortype, const char *,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||
extern void output_get_descr_header(char *);
|
||||
extern void output_get_descr(char *, char *);
|
||||
extern void output_set_descr_header(char *);
|
||||
|
@ -505,7 +505,7 @@ extern PGresult *pqPrepareAsyncResult(PGconn *conn);
|
||||
extern void
|
||||
pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
|
||||
/* This lets gcc check the format string for consistency. */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
extern int pqAddTuple(PGresult *res, PGresAttValue *tup);
|
||||
extern void pqSaveMessageField(PGresult *res, char code,
|
||||
const char *value);
|
||||
|
@ -141,7 +141,7 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
|
||||
extern void
|
||||
printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
/*------------------------
|
||||
* appendPQExpBuffer
|
||||
@ -153,7 +153,7 @@ __attribute__((format(printf, 2, 3)));
|
||||
extern void
|
||||
appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
/*------------------------
|
||||
* appendPQExpBufferStr
|
||||
|
@ -324,14 +324,14 @@ static void PLy_init_plpy(void);
|
||||
/* call PyErr_SetString with a vprint interface and translation support */
|
||||
static void
|
||||
PLy_exception_set(PyObject *, const char *,...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
/* same, with pluralized message */
|
||||
static void
|
||||
PLy_exception_set_plural(PyObject *, const char *, const char *,
|
||||
unsigned long n,...)
|
||||
__attribute__((format(printf, 2, 5)))
|
||||
__attribute__((format(printf, 3, 5)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 5)))
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 5)));
|
||||
|
||||
/* like PLy_exception_set, but conserve more fields from ErrorData */
|
||||
static void PLy_spi_exception_set(PyObject *excclass, ErrorData *edata);
|
||||
@ -342,7 +342,7 @@ static char *PLy_procedure_name(PLyProcedure *);
|
||||
/* some utility functions */
|
||||
static void
|
||||
PLy_elog(int, const char *,...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
static void PLy_get_spi_error_data(PyObject *exc, char **detail, char **hint, char **query, int *position);
|
||||
static void PLy_traceback(char **, char **, int *);
|
||||
|
||||
|
@ -126,17 +126,17 @@ static void
|
||||
header(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
static void
|
||||
status(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
static void
|
||||
psql_command(const char *database, const char *query,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
#ifdef WIN32
|
||||
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user