[Crosstoolchain-logs] [device-tree-compiler] 31/58: Add printf format 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 34a9886a177f9e22930cec7eccda88df4a9f4838
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Tue Feb 28 10:09:45 2017 +1100
Add printf format attributes
When compiling with gcc, we already include the attribute on check_msg()
to give compiler warnings about mismatches between printf() like format
strings and the corresponding arguments. This patch adds similar
attributes for lexical_error() and die().
Suggested-by: Nicolas Iooss <nicolas.iooss_linux at m4x.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
dtc-lexer.l | 6 ++++++
util.h | 14 +++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dtc-lexer.l b/dtc-lexer.l
index c600603..52bed7b 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -62,7 +62,13 @@ 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
+
%}
%%
diff --git a/util.h b/util.h
index 35b2bda..bc3d223 100644
--- a/util.h
+++ b/util.h
@@ -27,7 +27,13 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-static inline void __attribute__((noreturn)) die(const char *str, ...)
+#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
{
va_list ap;
@@ -59,7 +65,13 @@ 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 char *join_path(const char *path, const char *name);
/**
--
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