Skip to content

Commit 087667a

Browse files
committed
Don't use gai_strerror if not available
Identical check to #745
1 parent 10e33ec commit 087667a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/modbus-tcp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,11 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx)
407407
rc = getaddrinfo(ctx_tcp_pi->node, ctx_tcp_pi->service, &ai_hints, &ai_list);
408408
if (rc != 0) {
409409
if (ctx->debug) {
410+
#ifdef HAVE_GAI_STRERROR
410411
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
412+
#else
413+
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
414+
#endif
411415
}
412416
freeaddrinfo(ai_list);
413417
errno = ECONNREFUSED;
@@ -633,7 +637,11 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
633637
rc = getaddrinfo(node, service, &ai_hints, &ai_list);
634638
if (rc != 0) {
635639
if (ctx->debug) {
640+
#ifdef HAVE_GAI_STRERROR
636641
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
642+
#else
643+
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
644+
#endif
637645
}
638646
freeaddrinfo(ai_list);
639647
errno = ECONNREFUSED;

0 commit comments

Comments
 (0)