mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +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:
@@ -621,9 +621,9 @@ typedef NameData *Name;
|
||||
|
||||
/* only GCC supports the unused attribute */
|
||||
#ifdef __GNUC__
|
||||
#define pg_attribute_unused __attribute__((unused))
|
||||
#define pg_attribute_unused() __attribute__((unused))
|
||||
#else
|
||||
#define pg_attribute_unused
|
||||
#define pg_attribute_unused()
|
||||
#endif
|
||||
|
||||
/* GCC and XLC support format attributes */
|
||||
@@ -638,15 +638,16 @@ typedef NameData *Name;
|
||||
/* GCC, Sunpro and XLC support aligned, packed and noreturn */
|
||||
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
|
||||
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
|
||||
#define pg_attribute_noreturn __attribute__((noreturn))
|
||||
#define pg_attribute_packed __attribute__((packed))
|
||||
#define pg_attribute_noreturn() __attribute__((noreturn))
|
||||
#define pg_attribute_packed() __attribute__((packed))
|
||||
#define HAVE_PG_ATTRIBUTE_NORETURN 1
|
||||
#else
|
||||
/*
|
||||
* NB: aligned and packed are not defined as empty as they affect code
|
||||
* functionality; they must be implemented by the compiler if they are to be
|
||||
* used.
|
||||
* NB: aligned and packed are not given default definitions because they
|
||||
* affect code functionality; they *must* be implemented by the compiler
|
||||
* if they are to be used.
|
||||
*/
|
||||
#define pg_attribute_noreturn
|
||||
#define pg_attribute_noreturn()
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
@@ -995,7 +996,7 @@ typedef NameData *Name;
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
#define PG_USED_FOR_ASSERTS_ONLY
|
||||
#else
|
||||
#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused
|
||||
#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1059,10 +1060,7 @@ typedef NameData *Name;
|
||||
*/
|
||||
|
||||
#if !HAVE_DECL_SNPRINTF
|
||||
extern int
|
||||
snprintf(char *str, size_t count, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
pg_attribute_printf(3, 4);
|
||||
extern int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_VSNPRINTF
|
||||
|
Reference in New Issue
Block a user