mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Clean up gcc attributes
We have a number of explicit __GNUC__ conditionals to tell if we want to use some gcc extensions for extra warnings. This cleans this up to use a single conditional, defining convenience macros for those attributes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
49300f2ade
commit
672ac09ea0
5 changed files with 23 additions and 36 deletions
32
util.h
32
util.h
|
@ -25,15 +25,17 @@
|
|||
* USA
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PRINTF(i, j) __attribute__((format (printf, i, j)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
#define PRINTF(i, j)
|
||||
#define NORETURN
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#ifdef __GNUC__
|
||||
static inline void
|
||||
__attribute__((noreturn)) __attribute__((format (printf, 1, 2)))
|
||||
die(const char *str, ...)
|
||||
#else
|
||||
static inline void die(const char *str, ...)
|
||||
#endif
|
||||
static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
@ -66,12 +68,7 @@ static inline void *xrealloc(void *p, size_t len)
|
|||
|
||||
extern char *xstrdup(const char *s);
|
||||
|
||||
#ifdef __GNUC__
|
||||
extern int __attribute__((format (printf, 2, 3)))
|
||||
xasprintf(char **strp, const char *fmt, ...);
|
||||
#else
|
||||
extern int xasprintf(char **strp, const char *fmt, ...);
|
||||
#endif
|
||||
extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
|
||||
extern char *join_path(const char *path, const char *name);
|
||||
|
||||
/**
|
||||
|
@ -200,7 +197,7 @@ void utilfdt_print_data(const char *data, int len);
|
|||
/**
|
||||
* Show source version and exit
|
||||
*/
|
||||
void util_version(void) __attribute__((noreturn));
|
||||
void NORETURN util_version(void);
|
||||
|
||||
/**
|
||||
* Show usage and exit
|
||||
|
@ -214,9 +211,10 @@ void util_version(void) __attribute__((noreturn));
|
|||
* @param long_opts The structure of long options
|
||||
* @param opts_help An array of help strings (should align with long_opts)
|
||||
*/
|
||||
void util_usage(const char *errmsg, const char *synopsis,
|
||||
const char *short_opts, struct option const long_opts[],
|
||||
const char * const opts_help[]) __attribute__((noreturn));
|
||||
void NORETURN util_usage(const char *errmsg, const char *synopsis,
|
||||
const char *short_opts,
|
||||
struct option const long_opts[],
|
||||
const char * const opts_help[]);
|
||||
|
||||
/**
|
||||
* Show usage and exit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue