Skip to content

Commit

Permalink
Fix header includes and build failures on musl (#518)
Browse files Browse the repository at this point in the history
* Include stdint.h in files where its types are used

Signed-off-by: Moritz Kick <[email protected]>

* Fix type of len parameter passed to getsockopt

getsockopt expects socklen_t instead of int as its fifth argument

Signed-off-by: Moritz Kick <[email protected]>

* Remove unnecassary includes of netinet/tcp.h

also cleanup the second include of stdint.h in main.c

This commit fixes #331 and is a replacement for #344.

Signed-off-by: Moritz Kick <[email protected]>
  • Loading branch information
F1rebird authored and bmah888 committed Mar 22, 2017
1 parent b3828fe commit a8ee9c6
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/cjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "iperf_config.h"

#ifndef cJSON__h
#define cJSON__h

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

#ifdef __cplusplus
extern "C"
{
Expand Down
1 change: 1 addition & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#endif
#include <sys/select.h>
#include <sys/socket.h>
#define _GNU_SOURCE
#include <netinet/tcp.h>

#if defined(HAVE_CPUSET_SETAFFINITY)
Expand Down
1 change: 0 additions & 1 deletion src/iperf_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <sys/time.h>
#include <sys/select.h>

Expand Down
3 changes: 1 addition & 2 deletions src/iperf_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <netinet/tcp.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sched.h>
Expand Down Expand Up @@ -526,7 +525,7 @@ iperf_run_server(struct iperf_test *test)
}
}
{
int len = TCP_CA_NAME_MAX;
socklen_t len = TCP_CA_NAME_MAX;
char ca[TCP_CA_NAME_MAX + 1];
if (getsockopt(s, IPPROTO_TCP, TCP_CONGESTION, ca, &len) < 0) {
close(s);
Expand Down
1 change: 0 additions & 1 deletion src/iperf_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <sys/time.h>
#include <sys/select.h>

Expand Down
4 changes: 0 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <netinet/tcp.h>

#include "iperf.h"
#include "iperf_api.h"
Expand Down
5 changes: 5 additions & 0 deletions src/t_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* This code is distributed under a BSD style license, see the LICENSE
* file for complete information.
*/
#include "iperf_config.h"

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down
1 change: 0 additions & 1 deletion src/tcp_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <string.h>
#include <netinet/in.h>
#include <errno.h>
Expand Down
1 change: 0 additions & 1 deletion src/units.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/tcp.h>


#include "iperf.h"
Expand Down

0 comments on commit a8ee9c6

Please sign in to comment.