Skip to content

Commit

Permalink
Fix warning: "HAVE_SCTP" redefined (esnet#1010)
Browse files Browse the repository at this point in the history
The netinet/sctp.h header file defines HAVE_SCTP, so we have this
warning while building:

    In file included from ../../src/iperf.h:30,
                     from ../../src/iperf_sctp.c:46:
    ./iperf_config.h:44: warning: "HAVE_SCTP" redefined
       44 | #define HAVE_SCTP 1
          |
    In file included from ../../src/iperf_sctp.c:43:
    /usr/include/netinet/sctp.h:56: note: this is the location of the previous definition
       56 | #define HAVE_SCTP
          |

This patch replaces our HAVE_SCTP definition with HAVE_SCTP_H to avoid
this warning.

Signed-off-by: Stefano Garzarella <[email protected]>
  • Loading branch information
stefano-garzarella authored Jun 12, 2020
1 parent 8c8ef21 commit 0b0aa34
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -13416,7 +13416,7 @@ if test "x$ac_cv_header_netinet_sctp_h" = xyes; then :
#define HAVE_NETINET_SCTP_H 1
_ACEOF

$as_echo "#define HAVE_SCTP 1" >>confdefs.h
$as_echo "#define HAVE_SCTP_H 1" >>confdefs.h

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sctp_bindx" >&5
$as_echo_n "checking for library containing sctp_bindx... " >&6; }
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ AC_ARG_WITH([sctp],
if $try_sctp; then
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([netinet/sctp.h],
AC_DEFINE([HAVE_SCTP], [1], [Have SCTP support.])
AC_DEFINE([HAVE_SCTP_H], [1], [Have SCTP support.])
AC_SEARCH_LIBS(sctp_bindx, [sctp])
AC_CHECK_TYPES([struct sctp_assoc_value], [], [],
[[#include <netinet/sctp.h>]]),
Expand Down
20 changes: 10 additions & 10 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
#include "iperf_api.h"
#include "iperf_udp.h"
#include "iperf_tcp.h"
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
#include "iperf_sctp.h"
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
#include "timer.h"

#include "cjson.h"
Expand Down Expand Up @@ -848,7 +848,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"congestion", required_argument, NULL, 'C'},
{"linux-congestion", required_argument, NULL, 'C'},
#endif /* HAVE_TCP_CONGESTION */
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
{"sctp", no_argument, NULL, OPT_SCTP},
{"nstreams", required_argument, NULL, OPT_NUMSTREAMS},
{"xbind", required_argument, NULL, 'X'},
Expand Down Expand Up @@ -968,14 +968,14 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
client_flag = 1;
break;
case OPT_SCTP:
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
set_protocol(test, Psctp);
client_flag = 1;
break;
#else /* HAVE_SCTP */
#else /* HAVE_SCTP_H */
i_errno = IEUNIMP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */

case OPT_NUMSTREAMS:
#if defined(linux) || defined(__FreeBSD__)
Expand Down Expand Up @@ -2322,9 +2322,9 @@ int
iperf_defaults(struct iperf_test *testp)
{
struct protocol *tcp, *udp;
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
struct protocol *sctp;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */

testp->omit = OMIT;
testp->duration = DURATION;
Expand Down Expand Up @@ -2403,7 +2403,7 @@ iperf_defaults(struct iperf_test *testp)

set_protocol(testp, Ptcp);

#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
sctp = protocol_new();
if (!sctp) {
protocol_free(tcp);
Expand All @@ -2421,7 +2421,7 @@ iperf_defaults(struct iperf_test *testp)
sctp->init = iperf_sctp_init;

SLIST_INSERT_AFTER(udp, sctp, protocols);
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */

testp->on_new_stream = iperf_on_new_stream;
testp->on_test_start = iperf_on_test_start;
Expand Down
2 changes: 1 addition & 1 deletion src/iperf_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#undef HAVE_SCHED_SETAFFINITY

/* Have SCTP support. */
#undef HAVE_SCTP
#undef HAVE_SCTP_H

/* Define to 1 if you have the `sendfile' function. */
#undef HAVE_SENDFILE
Expand Down
4 changes: 2 additions & 2 deletions src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
#endif //HAVE_SSL
"Client specific:\n"
" -c, --client <host> run in client mode, connecting to <host>\n"
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
" --sctp use SCTP rather than TCP\n"
" -X, --xbind <name> bind SCTP association to links\n"
" --nstreams # number of SCTP streams\n"
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
" -u, --udp use UDP rather than TCP\n"
" --connect-timeout # timeout for control connection setup (ms)\n"
" -b, --bitrate #[KMG][/#] target bitrate in bits/sec (0 for unlimited)\n"
Expand Down
28 changes: 14 additions & 14 deletions src/iperf_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
int
iperf_sctp_recv(struct iperf_stream *sp)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
int r;

r = Nread(sp->socket, sp->buffer, sp->settings->blksize, Psctp);
Expand All @@ -78,7 +78,7 @@ iperf_sctp_recv(struct iperf_stream *sp)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}


Expand All @@ -89,7 +89,7 @@ iperf_sctp_recv(struct iperf_stream *sp)
int
iperf_sctp_send(struct iperf_stream *sp)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
int r;

r = Nwrite(sp->socket, sp->buffer, sp->settings->blksize, Psctp);
Expand All @@ -103,7 +103,7 @@ iperf_sctp_send(struct iperf_stream *sp)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}


Expand All @@ -115,7 +115,7 @@ iperf_sctp_send(struct iperf_stream *sp)
int
iperf_sctp_accept(struct iperf_test * test)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
int s;
signed char rbuf = ACCESS_DENIED;
char cookie[COOKIE_SIZE];
Expand Down Expand Up @@ -148,7 +148,7 @@ iperf_sctp_accept(struct iperf_test * test)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}


Expand All @@ -159,7 +159,7 @@ iperf_sctp_accept(struct iperf_test * test)
int
iperf_sctp_listen(struct iperf_test *test)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
struct addrinfo hints, *res;
char portstr[6];
int s, opt, saved_errno;
Expand Down Expand Up @@ -270,7 +270,7 @@ iperf_sctp_listen(struct iperf_test *test)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}


Expand All @@ -281,7 +281,7 @@ iperf_sctp_listen(struct iperf_test *test)
int
iperf_sctp_connect(struct iperf_test *test)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
int s, opt, saved_errno;
char portstr[6];
struct addrinfo hints, *local_res, *server_res;
Expand Down Expand Up @@ -527,20 +527,20 @@ iperf_sctp_connect(struct iperf_test *test)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}



int
iperf_sctp_init(struct iperf_test *test)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
return 0;
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}


Expand All @@ -552,7 +552,7 @@ iperf_sctp_init(struct iperf_test *test)
int
iperf_sctp_bindx(struct iperf_test *test, int s, int is_server)
{
#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
struct addrinfo hints;
char portstr[6];
char *servname;
Expand Down Expand Up @@ -701,5 +701,5 @@ iperf_sctp_bindx(struct iperf_test *test, int s, int is_server)
#else
i_errno = IENOSCTP;
return -1;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */
}
4 changes: 2 additions & 2 deletions src/iperf_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ get_optional_features(void)
numfeatures++;
#endif /* HAVE_FLOWLABEL */

#if defined(HAVE_SCTP)
#if defined(HAVE_SCTP_H)
if (numfeatures > 0) {
strncat(features, ", ",
sizeof(features) - strlen(features) - 1);
}
strncat(features, "SCTP",
sizeof(features) - strlen(features) - 1);
numfeatures++;
#endif /* HAVE_SCTP */
#endif /* HAVE_SCTP_H */

#if defined(HAVE_TCP_CONGESTION)
if (numfeatures > 0) {
Expand Down

0 comments on commit 0b0aa34

Please sign in to comment.