[Crosstoolchain-logs] [device-tree-compiler] 34/58: Clean up gcc attributes

Vagrant Cascadian vagrant at moszumanska.debian.org
Mon Sep 25 16:23:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

vagrant pushed a commit to branch debian/master
in repository device-tree-compiler.

commit 672ac09ea04d998dfddfdef3070a8af8d480182b
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Mon Mar 6 12:06:15 2017 +1100

    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 at gibson.dropbear.id.au>
---
 checks.c    |  8 ++------
 dtc-lexer.l |  7 +------
 dtc.h       |  1 -
 srcpos.h    | 11 +++++------
 util.h      | 30 ++++++++++++++----------------
 5 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/checks.c b/checks.c
index 0e8b978..4b3e1cb 100644
--- a/checks.c
+++ b/checks.c
@@ -72,12 +72,8 @@ struct check {
 #define CHECK(_nm, _fn, _d, ...) \
 	CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
 
-#ifdef __GNUC__
-static inline void check_msg(struct check *c, struct dt_info *dti,
-			     const char *fmt, ...) __attribute__((format (printf, 3, 4)));
-#endif
-static inline void check_msg(struct check *c, struct dt_info *dti,
-			     const char *fmt, ...)
+static inline void  PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,
+					   const char *fmt, ...)
 {
 	va_list ap;
 	va_start(ap, fmt);
diff --git a/dtc-lexer.l b/dtc-lexer.l
index 52bed7b..fd825eb 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -62,12 +62,7 @@ static int dts_version = 1;
 
 static void push_input_file(const char *filename);
 static bool pop_input_file(void);
-#ifdef __GNUC__
-static void lexical_error(const char *fmt, ...)
-	__attribute__((format (printf, 1, 2)));
-#else
-static void lexical_error(const char *fmt, ...);
-#endif
+static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
 
 %}
 
diff --git a/dtc.h b/dtc.h
index 26b4beb..403b79d 100644
--- a/dtc.h
+++ b/dtc.h
@@ -43,7 +43,6 @@
 #define debug(...)
 #endif
 
-
 #define DEFAULT_FDT_VERSION	17
 
 /*
diff --git a/srcpos.h b/srcpos.h
index 2cdfcd8..7caca82 100644
--- a/srcpos.h
+++ b/srcpos.h
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <stdbool.h>
+#include "util.h"
 
 struct srcfile_state {
 	FILE *f;
@@ -106,12 +107,10 @@ extern void srcpos_update(struct srcpos *pos, const char *text, int len);
 extern struct srcpos *srcpos_copy(struct srcpos *pos);
 extern char *srcpos_string(struct srcpos *pos);
 
-extern void srcpos_verror(struct srcpos *pos, const char *prefix,
-			  const char *fmt, va_list va)
-	__attribute__((format(printf, 3, 0)));
-extern void srcpos_error(struct srcpos *pos, const char *prefix,
-			 const char *fmt, ...)
-	__attribute__((format(printf, 3, 4)));
+extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix,
+					const char *fmt, va_list va);
+extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix,
+				      const char *fmt, ...);
 
 extern void srcpos_set_line(char *f, int l);
 
diff --git a/util.h b/util.h
index bc3d223..ad5f411 100644
--- a/util.h
+++ b/util.h
@@ -25,15 +25,17 @@
  *                                                                   USA
  */
 
-#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, ...)
+#define PRINTF(i, j)	__attribute__((format (printf, i, j)))
+#define NORETURN	__attribute__((noreturn))
 #else
-static inline void die(const char *str, ...)
+#define PRINTF(i, j)
+#define NORETURN
 #endif
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list