Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | Upstream-Status: Backport |
| 2 | |
| 3 | Backport from https://github.com/xelerance/xl2tpd/commit/9098f64950eb22cf049058d40f647bafdb822174 |
| 4 | |
| 5 | Signed-off-by: Kai Kang <kai.kang@windriver.com> |
| 6 | --- |
| 7 | From 9098f64950eb22cf049058d40f647bafdb822174 Mon Sep 17 00:00:00 2001 |
| 8 | From: Kai Kang <kai.kang@windriver.com> |
| 9 | Date: Wed, 23 Sep 2015 10:41:05 +0800 |
| 10 | Subject: [PATCH] Fix build errors caused by inline function with gcc 5 |
| 11 | |
| 12 | GCC 5 defaults to -std=gnu11 instead of -std=gnu89. And -std=gnu89 |
| 13 | employs the GNU89 inline semantics, -std=gnu11 uses the C99 inline |
| 14 | semantics. |
| 15 | |
| 16 | For 'inline' fuction, it is NOT exported by C99. So error messages such as: |
| 17 | |
| 18 | | control.c:1717: undefined reference to `check_control' |
| 19 | |
| 20 | For these functions which is not referred by other compile units, make |
| 21 | them 'static inline'. |
| 22 | |
| 23 | For 'extern inline' function, it fails such as: |
| 24 | |
| 25 | | misc.h:68:20: warning: inline function 'swaps' declared but never defined |
| 26 | | extern inline void swaps (void *, int); |
| 27 | | ^ |
| 28 | |
| 29 | Because function swaps() is referred by other compile units, it must be |
| 30 | exported. The semantics of 'extern inline' are not same between GNU89 |
| 31 | and C99, so remove 'inline' attribute for compatible with GNU89. |
| 32 | |
| 33 | Ref: |
| 34 | https://gcc.gnu.org/gcc-5/porting_to.html |
| 35 | |
| 36 | Signed-off-by: Kai Kang <kai.kang@windriver.com> |
| 37 | --- |
| 38 | control.c | 8 ++++---- |
| 39 | misc.c | 2 +- |
| 40 | misc.h | 2 +- |
| 41 | network.c | 4 ++-- |
| 42 | 4 files changed, 8 insertions(+), 8 deletions(-) |
| 43 | |
| 44 | diff --git a/control.c b/control.c |
| 45 | index b2891a9..c4a39b5 100644 |
| 46 | --- a/control.c |
| 47 | +++ b/control.c |
| 48 | @@ -1140,7 +1140,7 @@ int control_finish (struct tunnel *t, struct call *c) |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | -inline int check_control (const struct buffer *buf, struct tunnel *t, |
| 53 | +static inline int check_control (const struct buffer *buf, struct tunnel *t, |
| 54 | struct call *c) |
| 55 | { |
| 56 | /* |
| 57 | @@ -1276,7 +1276,7 @@ inline int check_control (const struct buffer *buf, struct tunnel *t, |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | -inline int check_payload (struct buffer *buf, struct tunnel *t, |
| 62 | +static inline int check_payload (struct buffer *buf, struct tunnel *t, |
| 63 | struct call *c) |
| 64 | { |
| 65 | /* |
| 66 | @@ -1382,7 +1382,7 @@ inline int check_payload (struct buffer *buf, struct tunnel *t, |
| 67 | #endif |
| 68 | return 0; |
| 69 | } |
| 70 | -inline int expand_payload (struct buffer *buf, struct tunnel *t, |
| 71 | +static inline int expand_payload (struct buffer *buf, struct tunnel *t, |
| 72 | struct call *c) |
| 73 | { |
| 74 | /* |
| 75 | @@ -1562,7 +1562,7 @@ void send_zlb (void *data) |
| 76 | toss (buf); |
| 77 | } |
| 78 | |
| 79 | -inline int write_packet (struct buffer *buf, struct tunnel *t, struct call *c, |
| 80 | +static inline int write_packet (struct buffer *buf, struct tunnel *t, struct call *c, |
| 81 | int convert) |
| 82 | { |
| 83 | /* |
| 84 | diff --git a/misc.c b/misc.c |
| 85 | index 3092401..af90dbf 100644 |
| 86 | --- a/misc.c |
| 87 | +++ b/misc.c |
| 88 | @@ -170,7 +170,7 @@ void do_packet_dump (struct buffer *buf) |
| 89 | printf ("}\n"); |
| 90 | } |
| 91 | |
| 92 | -inline void swaps (void *buf_v, int len) |
| 93 | +void swaps (void *buf_v, int len) |
| 94 | { |
| 95 | #ifdef __alpha |
| 96 | /* Reverse byte order alpha is little endian so lest save a step. |
| 97 | diff --git a/misc.h b/misc.h |
| 98 | index aafdc62..caab7a1 100644 |
| 99 | --- a/misc.h |
| 100 | +++ b/misc.h |
| 101 | @@ -65,7 +65,7 @@ extern void l2tp_log (int level, const char *fmt, ...); |
| 102 | extern struct buffer *new_buf (int); |
| 103 | extern void udppush_handler (int); |
| 104 | extern int addfcs (struct buffer *buf); |
| 105 | -extern inline void swaps (void *, int); |
| 106 | +extern void swaps (void *, int); |
| 107 | extern void do_packet_dump (struct buffer *); |
| 108 | extern void status (const char *fmt, ...); |
| 109 | extern void status_handler (int signal); |
| 110 | diff --git a/network.c b/network.c |
| 111 | index b1268c6..d324a71 100644 |
| 112 | --- a/network.c |
| 113 | +++ b/network.c |
| 114 | @@ -135,7 +135,7 @@ int init_network (void) |
| 115 | return 0; |
| 116 | } |
| 117 | |
| 118 | -inline void extract (void *buf, int *tunnel, int *call) |
| 119 | +static inline void extract (void *buf, int *tunnel, int *call) |
| 120 | { |
| 121 | /* |
| 122 | * Extract the tunnel and call #'s, and fix the order of the |
| 123 | @@ -155,7 +155,7 @@ inline void extract (void *buf, int *tunnel, int *call) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | -inline void fix_hdr (void *buf) |
| 128 | +static inline void fix_hdr (void *buf) |
| 129 | { |
| 130 | /* |
| 131 | * Fix the byte order of the header |
| 132 | -- |
| 133 | 2.6.1 |
| 134 | |