052bf4b0851bdb8bb99dfa0e1fc7506fcdbdca44
[buildroot.git] /
1 From 67c2a89004f867151d0ad6acc5e10dee76be454f Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Tue, 2 Sep 2014 21:57:30 +0200
4 Subject: [PATCH] os/log: adjust gcc version conditions for #pragma
5
6 In commit e67f2d7e0f9189beb2907fa06cff5ecc7f35f922 ("gcc 4.2.1 doesn't
7 support #pragma GCC diagnostic ignored"), some compile time
8 conditionals were added around the #pragma usage. Those conditionals
9 ensure that the #pragma are not used on gcc <= 4.2.
10
11 However, the usage of #pragma diagnostic inside functions was only
12 added in gcc 4.6, and a build failure is therefore experienced with
13 gcc 4.5:
14
15 log.c: In function 'LogInit':
16 log.c:199:9: error: #pragma GCC diagnostic not allowed inside functions
17 log.c:201:9: warning: format not a string literal, argument types not checked
18 log.c:212:9: error: #pragma GCC diagnostic not allowed inside functions
19 log.c:214:17: warning: format not a string literal, argument types not checked
20
21 $ ./host/usr/bin/powerpc-linux-gnu-gcc -v
22 [...]
23 gcc version 4.5.2 (Sourcery G++ Lite 2011.03-38)
24
25 This patch therefore adjusts the compile time conditionals to make
26 sure the #pragma is not used on gcc <= 4.5, and only used on gcc >=
27 4.6.
28
29 Submitted upstream:
30
31 http://lists.x.org/archives/xorg-devel/2014-September/043716.html
32
33 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
34 ---
35 os/log.c | 4 ++--
36 1 file changed, 2 insertions(+), 2 deletions(-)
37
38 diff --git a/os/log.c b/os/log.c
39 index 2a721b9..629021e 100644
40 --- a/os/log.c
41 +++ b/os/log.c
42 @@ -195,7 +195,7 @@ LogInit(const char *fname, const char *backup)
43 char *logFileName = NULL;
44
45 if (fname && *fname) {
46 -#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2
47 +#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 5
48 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
49 #endif
50 if (asprintf(&logFileName, fname, display) == -1)
51 @@ -208,7 +208,7 @@ LogInit(const char *fname, const char *backup)
52 char *suffix;
53 char *oldLog;
54
55 -#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2
56 +#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 5
57 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
58 #endif
59 if ((asprintf(&suffix, backup, display) == -1) ||
60 --
61 2.0.0
62