summaryrefslogtreecommitdiff
path: root/package/network/utils/iperf3/patches/010-iperf-3.3-fix-build-warnings.patch
blob: d617ba9f40188ae0724b351efcb7f988a33be6ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
The following patches are taken directly from:

https://github.com/esnet/iperf/pull/664

as an upstream submission.

commit b63d41b25f49a76d0be66edfb61bd4cb68921d55
Author: Philip Prindeville <philipp@redfish-solutions.com>
Date:   Tue Oct 31 13:41:08 2017 -0600

    Fix warnings about _GNU_SOURCE being redefined.
    
    Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>

diff --git a/src/iperf.h b/src/iperf.h
index bb951dc..b656784 100755
--- a/src/iperf.h
+++ b/src/iperf.h
@@ -36,7 +36,9 @@
 #endif
 #include <sys/select.h>
 #include <sys/socket.h>
-#define _GNU_SOURCE
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
 #include <netinet/tcp.h>
 
 #if defined(HAVE_CPUSET_SETAFFINITY)
diff --git a/src/iperf_api.c b/src/iperf_api.c
index ab30b93..9e41238 100755
--- a/src/iperf_api.c
+++ b/src/iperf_api.c
@@ -24,7 +24,9 @@
  * This code is distributed under a BSD style license, see the LICENSE file
  * for complete information.
  */
-#define _GNU_SOURCE
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
 #define __USE_GNU
 
 #include "iperf_config.h"

commit 315254cfc5f5682627f4a46ade3100bc3c64cfcc
Author: Philip Prindeville <philipp@redfish-solutions.com>
Date:   Tue Oct 31 13:42:58 2017 -0600

    Fix warnings of format-specified mismatching type
    
    Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>

diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c
index 91cf032..6f86d5d 100644
--- a/src/iperf_tcp.c
+++ b/src/iperf_tcp.c
@@ -24,8 +24,6 @@
  * This code is distributed under a BSD style license, see the LICENSE
  * file for complete information.
  */
-#include "iperf_config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -44,6 +42,12 @@
 #include "net.h"
 #include "cjson.h"
 
+#if defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#else
+# define PRIu64		"llu"
+#endif
+
 #if defined(HAVE_FLOWLABEL)
 #include "flowlabel.h"
 #endif /* HAVE_FLOWLABEL */
@@ -90,7 +94,7 @@ iperf_tcp_send(struct iperf_stream *sp)
     sp->result->bytes_sent_this_interval += r;
 
     if (sp->test->debug)
-	printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
+	printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
 
     return r;
 }
diff --git a/src/iperf_udp.c b/src/iperf_udp.c
index a2ea6d0..d04ae44 100644
--- a/src/iperf_udp.c
+++ b/src/iperf_udp.c
@@ -48,6 +48,12 @@
 #include "cjson.h"
 #include "portable_endian.h"
 
+#if defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#else
+# define PRIu64		"llu"
+#endif
+
 /* iperf_udp_recv
  *
  * receives the data for UDP
@@ -98,7 +104,7 @@ iperf_udp_recv(struct iperf_stream *sp)
     }
 
     if (sp->test->debug)
-	fprintf(stderr, "pcount %llu packet_count %d\n", pcount, sp->packet_count);
+	fprintf(stderr, "pcount %" PRIu64 " packet_count %d\n", pcount, sp->packet_count);
 
     /*
      * Try to handle out of order packets.  The way we do this
@@ -141,7 +147,7 @@ iperf_udp_recv(struct iperf_stream *sp)
 	
 	/* Log the out-of-order packet */
 	if (sp->test->debug) 
-	    fprintf(stderr, "OUT OF ORDER - incoming packet sequence %llu but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
+	    fprintf(stderr, "OUT OF ORDER - incoming packet sequence %" PRIu64 " but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
     }
 
     /*
@@ -220,7 +226,7 @@ iperf_udp_send(struct iperf_stream *sp)
     sp->result->bytes_sent_this_interval += r;
 
     if (sp->test->debug)
-	printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
+	printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
 
     return r;
 }

commit 9a66b3b0349e0a158bb4940b668a5cbc7c245762
Author: Philip Prindeville <philipp@redfish-solutions.com>
Date:   Tue Oct 31 13:44:34 2017 -0600

    Simplify endianness checks
    
    Linux can be built with too many types of C run-time library and it's
    not reasonable to have to enumerate all of them, especially since at
    least one of them (MUSL) goes out of its way to not be easily
    detectable.
    
    Instead, leverage autoconf better for Linux/BSD to detect either
    <endian.h> or <sys/endian.h> directly.
    
    Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>

diff --git a/configure.ac b/configure.ac
index f57e83f..cfb42ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,14 @@ AC_CHECK_HEADERS([netinet/sctp.h],
 #endif
 ])
 
+AC_CHECK_HEADER([endian.h],
+		AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]),
+		AC_CHECK_HEADER([sys/endian.h],
+				AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]),
+				AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.])
+				)
+		)
+
 if test "x$with_openssl" = "xno"; then
     AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] )
 else
diff --git a/src/iperf_config.h.in b/src/iperf_config.h.in
index bd03935..a9e51ec 100644
--- a/src/iperf_config.h.in
+++ b/src/iperf_config.h.in
@@ -9,6 +9,9 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
 /* Have IPv6 flowlabel support. */
 #undef HAVE_FLOWLABEL
 
@@ -54,6 +57,9 @@
 /* Define to 1 if the system has the type `struct sctp_assoc_value'. */
 #undef HAVE_STRUCT_SCTP_ASSOC_VALUE
 
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
diff --git a/src/portable_endian.h b/src/portable_endian.h
index b86d37a..5dbc6e5 100644
--- a/src/portable_endian.h
+++ b/src/portable_endian.h
@@ -10,14 +10,33 @@
 
 #endif
 
-// GLIBC / Linux with endian(3) support, which was added in glibc 2.9.
-// Intended to support CentOS 6 and newer.
-#if defined(__linux__) && \
-    ((__GLIBC__ > 3) || \
-     (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9))
-
+#if defined(HAVE_ENDIAN_H)
 #	include <endian.h>
 
+#elif defined(HAVE_SYS_ENDIAN_H)
+#	include <sys/endian.h>
+
+#	if defined(__OpenBSD__)
+
+#		define be16toh(x) betoh16(x)
+#		define le16toh(x) letoh16(x)
+
+#		define be32toh(x) betoh32(x)
+#		define le32toh(x) letoh32(x)
+
+#		define be64toh(x) betoh64(x)
+#		define le64toh(x) letoh64(x)
+
+#	elif defined(__sgi)
+
+#		include <netinet/in.h>
+#		include <inttypes.h>
+
+#		define be64toh(x) (x)
+#		define htobe64(x) (x)
+
+#	endif
+
 #elif defined(__CYGWIN__)
 
 #	include <endian.h>
@@ -46,32 +65,6 @@
 #	define __LITTLE_ENDIAN LITTLE_ENDIAN
 #	define __PDP_ENDIAN    PDP_ENDIAN
 
-#elif defined(__OpenBSD__)
-
-#	include <sys/endian.h>
-
-#	define be16toh(x) betoh16(x)
-#	define le16toh(x) letoh16(x)
-
-#	define be32toh(x) betoh32(x)
-#	define le32toh(x) letoh32(x)
-
-#	define be64toh(x) betoh64(x)
-#	define le64toh(x) letoh64(x)
-
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
-
-#	include <sys/endian.h>
-
-#elif defined(__sgi)
-
-#  include <sys/endian.h>
-#  include <netinet/in.h>
-#  include <inttypes.h>
-
-#  define be64toh(x) (x)
-#  define htobe64(x) (x)
-
 #elif defined(__sun) && defined(__SVR4)
 
 #	include <sys/types.h>

commit 7e7285d0daf92ef7beda8f78a6f63cc647a77f38
Author: Philip Prindeville <philipp@redfish-solutions.com>
Date:   Tue Oct 31 13:48:06 2017 -0600

    Sys headers should not be included directly
    
    There's usually a top-level header which then includes the sys/
    descendent.
    
    Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>

diff --git a/src/net.c b/src/net.c
index af456cb..afd0022 100644
--- a/src/net.c
+++ b/src/net.c
@@ -31,13 +31,12 @@
 #include <errno.h>
 #include <sys/socket.h>
 #include <sys/types.h>
-#include <sys/errno.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <assert.h>
 #include <netdb.h>
 #include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #ifdef HAVE_SENDFILE
 #ifdef linux