summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-01-24 19:33:25 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-01-24 19:33:25 +0900
commit0f417d640de16339c85ba8f4bd60e6ac2ce506eb (patch)
treec5c4fe161dd897bcf06b692e9a0ff2abd11d3484 /ext/socket
parent4099b04c099899d92dab3f34f1152038ed718d79 (diff)
Initialize errno variables and fix maybe-uninitialized warnings
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/raddrinfo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index cdb785f268..e79bcfa332 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -481,7 +481,7 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
{
int retry;
struct getaddrinfo_arg *arg;
- int err, gai_errno;
+ int err, gai_errno = 0;
start:
retry = 0;
@@ -531,7 +531,7 @@ start:
/* Because errno is threadlocal, the errno value we got from the call to getaddrinfo() in the thread
* (in case of EAI_SYSTEM return value) is not propagated to the caller of _this_ function. Set errno
* explicitly, as round-tripped through struct getaddrinfo_arg, to deal with that */
- errno = gai_errno;
+ if (gai_errno) errno = gai_errno;
return err;
}
@@ -700,7 +700,7 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
{
int retry;
struct getnameinfo_arg *arg;
- int err, gni_errno;
+ int err, gni_errno = 0;
start:
retry = 0;
@@ -750,7 +750,7 @@ start:
/* Make sure we copy the thread-local errno value from the getnameinfo thread back to this thread, so
* calling code sees the correct errno */
- errno = gni_errno;
+ if (gni_errno) errno = gni_errno;
return err;
}