Skip to content

Commit

Permalink
Don't use gai_strerror if not available
Browse files Browse the repository at this point in the history
Identical check to #745
  • Loading branch information
stephane committed Jul 16, 2024
1 parent 10e33ec commit 087667a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modbus-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,11 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx)
rc = getaddrinfo(ctx_tcp_pi->node, ctx_tcp_pi->service, &ai_hints, &ai_list);
if (rc != 0) {
if (ctx->debug) {
#ifdef HAVE_GAI_STRERROR
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
#else
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
#endif
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
Expand Down Expand Up @@ -633,7 +637,11 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
rc = getaddrinfo(node, service, &ai_hints, &ai_list);
if (rc != 0) {
if (ctx->debug) {
#ifdef HAVE_GAI_STRERROR
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
#else
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
#endif
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
Expand Down

0 comments on commit 087667a

Please sign in to comment.