summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenzong Fan <wenzong.fan@windriver.com>2015-09-14 04:45:06 -0400
committerJoe MacDonald <joe_macdonald@mentor.com>2015-09-21 10:42:27 -0400
commit463f97bfd1180475540b7d91e3fec6a2b33966bd (patch)
tree1248c6695cfd8c97385ef61359766ca4e8df6825
parentdfa1054f3330af3fa18f522488af88e4269e394c (diff)
downloadmeta-selinux-463f97bfd1180475540b7d91e3fec6a2b33966bd.tar.gz
audit/auvirt: get inline functions work with both gnu89 & gnu11
After gcc upgraded to gcc5, and if the codes are compiled without optimization (-O0), and the below error will happen: auvirt.c:484: undefined reference to `copy_str' auvirt.c:667: undefined reference to `is_resource' collect2: error: ld returned 1 exit status gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that exactly one C source file has the callable copy of the inline function. Consider the following program: inline int foo (void) { return 42; } int main (void) { return foo (); } The program above will not link with the C99 inline semantics, because no out-of-line function foo is generated. To fix this, either mark the function foo as static, or add the following declaration: static inline int foo (void); More information refer to: https://gcc.gnu.org/gcc-5/porting_to.html Note: using "extern inline" will fail to build with gcc4.x, so replace inline with "static inline". Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
-rw-r--r--recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch71
-rw-r--r--recipes-security/audit/audit_2.4.3.bb1
2 files changed, 72 insertions, 0 deletions
diff --git a/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch b/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch
new file mode 100644
index 0000000..578cfc1
--- /dev/null
+++ b/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch
@@ -0,0 +1,71 @@
1From 15036dd4fa9eb209f5e148c6f7ee081f5ca78fa4 Mon Sep 17 00:00:00 2001
2From: Wenzong Fan <wenzong.fan@windriver.com>
3Date: Fri, 11 Sep 2015 03:37:13 -0400
4Subject: [PATCH] audit/auvirt: get inline functions work with both gnu89 & gnu11
5
6After gcc upgraded to gcc5, and if the codes are compiled without
7optimization (-O0), and the below error will happen:
8
9 auvirt.c:484: undefined reference to `copy_str'
10 auvirt.c:667: undefined reference to `is_resource'
11 collect2: error: ld returned 1 exit status
12
13gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that
14exactly one C source file has the callable copy of the inline function.
15Consider the following program:
16
17 inline int
18 foo (void)
19 {
20 return 42;
21 }
22
23 int
24 main (void)
25 {
26 return foo ();
27 }
28
29The program above will not link with the C99 inline semantics, because
30no out-of-line function foo is generated. To fix this, either mark the
31function foo as static, or add the following declaration:
32
33 static inline int foo (void);
34
35More information refer to: https://gcc.gnu.org/gcc-5/porting_to.html
36
37Note: using "extern inline" will fail to build with gcc4.x, so replace
38inline with "static inline".
39
40Upstream-Status: Pending
41
42Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
43---
44 tools/auvirt/auvirt.c | 4 ++--
45 1 file changed, 2 insertions(+), 2 deletions(-)
46
47diff --git a/tools/auvirt/auvirt.c b/tools/auvirt/auvirt.c
48index 655c454..b16d718 100644
49--- a/tools/auvirt/auvirt.c
50+++ b/tools/auvirt/auvirt.c
51@@ -138,7 +138,7 @@ void event_free(struct event *event)
52 }
53 }
54
55-inline char *copy_str(const char *str)
56+static inline char *copy_str(const char *str)
57 {
58 return (str) ? strdup(str) : NULL;
59 }
60@@ -650,7 +650,7 @@ int process_control_event(auparse_state_t *au)
61 return 0;
62 }
63
64-inline int is_resource(const char *res)
65+static inline int is_resource(const char *res)
66 {
67 if (res == NULL ||
68 res[0] == '\0' ||
69--
701.9.1
71
diff --git a/recipes-security/audit/audit_2.4.3.bb b/recipes-security/audit/audit_2.4.3.bb
index 0fcf145..f0fa949 100644
--- a/recipes-security/audit/audit_2.4.3.bb
+++ b/recipes-security/audit/audit_2.4.3.bb
@@ -15,6 +15,7 @@ SRC_URI = "http://people.redhat.com/sgrubb/audit/audit-${PV}.tar.gz \
15 file://auditd \ 15 file://auditd \
16 file://auditd.service \ 16 file://auditd.service \
17 file://audit-volatile.conf \ 17 file://audit-volatile.conf \
18 file://audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch \
18" 19"
19SRC_URI[md5sum] = "544d863af2016b76afd8d1691b251164" 20SRC_URI[md5sum] = "544d863af2016b76afd8d1691b251164"
20SRC_URI[sha256sum] = "9c914704fecc602e143e37152f3efbab2469692684c1a8cc1b801c1b49c7abc6" 21SRC_URI[sha256sum] = "9c914704fecc602e143e37152f3efbab2469692684c1a8cc1b801c1b49c7abc6"