Fix 3.3 build warnings (#664)
* Fix warnings about _GNU_SOURCE being redefined. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> * Fix warnings of format-specified mismatching type Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> * 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> * 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>
Этот коммит содержится в:
родитель
e44ec101bb
Коммит
d88f4cecf3
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -10,18 +10,37 @@
|
||||
|
||||
#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(__CYGWIN__)
|
||||
|
||||
# include <endian.h>
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
|
||||
#elif 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(__APPLE__)
|
||||
|
||||
# include <libkern/OSByteOrder.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>
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user