Skip to content

Commit 5b63f35

Browse files
authored
core/iwasm/libraries/lib-socket/test/nslookup.c: use gai_strerror (#4532)
1 parent f5b7418 commit 5b63f35

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/iwasm/libraries/lib-socket/test/nslookup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <assert.h>
7+
#include <errno.h>
78
#include <string.h>
89
#include <stdio.h>
910
#include <pthread.h>
@@ -28,6 +29,15 @@ test_nslookup(int af)
2829
hints.ai_family = af;
2930
hints.ai_socktype = SOCK_STREAM;
3031
int ret = getaddrinfo(url, 0, &hints, &res);
32+
if (ret != 0) {
33+
if (ret == EAI_SYSTEM) {
34+
fprintf(stderr, "getaddrinfo failed: %s (%s)\n", gai_strerror(ret),
35+
strerror(errno));
36+
}
37+
else {
38+
fprintf(stderr, "getaddrinfo failed: %s\n", gai_strerror(ret));
39+
}
40+
}
3141
assert(ret == 0);
3242
struct addrinfo *address = res;
3343
while (address) {

0 commit comments

Comments
 (0)