mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Tweak __attribute__-wrapping macros for better pgindent results.
This improves on commit bbfd7edae5
by
making two simple changes:
* pg_attribute_noreturn now takes parentheses, ie pg_attribute_noreturn().
Likewise pg_attribute_unused(), pg_attribute_packed(). This reduces
pgindent's tendency to misformat declarations involving them.
* attributes are now always attached to function declarations, not
definitions. Previously some places were taking creative shortcuts,
which were not merely candidates for bad misformatting by pgindent
but often were outright wrong anyway. (It does little good to put a
noreturn annotation where callers can't see it.) In any case, if
we would like to believe that these macros can be used with non-gcc
compilers, we should avoid gratuitous variance in usage patterns.
I also went through and manually improved the formatting of a lot of
declarations, and got rid of excessively repetitive (and now obsolete
anyway) comments informing the reader what pg_attribute_printf is for.
This commit is contained in:
@ -13,9 +13,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
extern char *
|
||||
ecpg_gettext(const char *msgid)
|
||||
pg_attribute_format_arg(1);
|
||||
extern char *ecpg_gettext(const char *msgid) pg_attribute_format_arg(1);
|
||||
#else
|
||||
#define ecpg_gettext(x) (x)
|
||||
#endif
|
||||
|
@ -61,10 +61,12 @@ struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
|
||||
|
||||
static struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
|
||||
|
||||
static void vmmerror(int error_code, enum errortype type, const char *error, va_list ap) pg_attribute_printf(3, 0);
|
||||
|
||||
/*
|
||||
* Handle parsing errors and warnings
|
||||
*/
|
||||
static void pg_attribute_printf(3, 0)
|
||||
static void
|
||||
vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
|
||||
{
|
||||
/* localize the error message string */
|
||||
|
@ -78,7 +78,7 @@ extern void base_yyerror(const char *);
|
||||
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
|
||||
extern char *mm_strdup(const char *);
|
||||
extern void mmerror(int errorcode, enum errortype type, const char *error,...) pg_attribute_printf(3, 4);
|
||||
extern void mmfatal(int errorcode, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn;
|
||||
extern void mmfatal(int errorcode, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn();
|
||||
extern void output_get_descr_header(char *);
|
||||
extern void output_get_descr(char *, char *);
|
||||
extern void output_set_descr_header(char *);
|
||||
|
@ -545,10 +545,7 @@ extern char *pqResultStrdup(PGresult *res, const char *str);
|
||||
extern void pqClearAsyncResult(PGconn *conn);
|
||||
extern void pqSaveErrorResult(PGconn *conn);
|
||||
extern PGresult *pqPrepareAsyncResult(PGconn *conn);
|
||||
extern void
|
||||
pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
|
||||
/* This lets gcc check the format string for consistency. */
|
||||
pg_attribute_printf(2, 3);
|
||||
extern void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...) pg_attribute_printf(2, 3);
|
||||
extern void pqSaveMessageField(PGresult *res, char code,
|
||||
const char *value);
|
||||
extern void pqSaveParameterStatus(PGconn *conn, const char *name,
|
||||
@ -651,12 +648,8 @@ extern ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len);
|
||||
#define pqIsnonblocking(conn) ((conn)->nonblocking)
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
extern char *
|
||||
libpq_gettext(const char *msgid)
|
||||
pg_attribute_format_arg(1);
|
||||
extern char *
|
||||
libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n)
|
||||
pg_attribute_format_arg(1) pg_attribute_format_arg(2);
|
||||
extern char *libpq_gettext(const char *msgid) pg_attribute_format_arg(1);
|
||||
extern char *libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n) pg_attribute_format_arg(1) pg_attribute_format_arg(2);
|
||||
#else
|
||||
#define libpq_gettext(x) (x)
|
||||
#define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p))
|
||||
|
@ -37,9 +37,7 @@
|
||||
/* All "broken" PQExpBuffers point to this string. */
|
||||
static const char oom_buffer[1] = "";
|
||||
|
||||
static bool
|
||||
appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args)
|
||||
pg_attribute_printf(2, 0);
|
||||
static bool appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args) pg_attribute_printf(2, 0);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -146,10 +146,7 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
|
||||
* This is a convenience routine that does the same thing as
|
||||
* resetPQExpBuffer() followed by appendPQExpBuffer().
|
||||
*/
|
||||
extern void
|
||||
printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
pg_attribute_printf(2, 3);
|
||||
extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
|
||||
|
||||
/*------------------------
|
||||
* appendPQExpBuffer
|
||||
@ -158,10 +155,7 @@ pg_attribute_printf(2, 3);
|
||||
* to str if necessary. This is sort of like a combination of sprintf and
|
||||
* strcat.
|
||||
*/
|
||||
extern void
|
||||
appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
pg_attribute_printf(2, 3);
|
||||
extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
|
||||
|
||||
/*------------------------
|
||||
* appendPQExpBufferStr
|
||||
|
@ -34,9 +34,7 @@
|
||||
|
||||
/* Declared here to avoid pulling in all includes, which causes name collissions */
|
||||
#ifdef ENABLE_NLS
|
||||
extern char *
|
||||
libpq_gettext(const char *msgid)
|
||||
pg_attribute_format_arg(1);
|
||||
extern char *libpq_gettext(const char *msgid) pg_attribute_format_arg(1);
|
||||
#else
|
||||
#define libpq_gettext(x) (x)
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user