Update struct initializer to work with relatively older C++.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-09-20 19:13:17 +09:00
parent 8be78dbf9d
commit d6dd6f0e7b
5 changed files with 17 additions and 15 deletions
+7 -8
View File
@@ -66,8 +66,8 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
{
if (af == AF_INET)
{
struct sockaddr_in in;
in = (struct sockaddr_in){0};
struct sockaddr_in in = {0};
in.sin_family = AF_INET;
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
getnameinfo((struct sockaddr *)&in, sizeof(struct
@@ -76,8 +76,8 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
}
else if (af == AF_INET6)
{
struct sockaddr_in6 in;
in = (struct sockaddr_in6){0};
struct sockaddr_in6 in = {0};
in.sin6_family = AF_INET6;
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
getnameinfo((struct sockaddr *)&in, sizeof(struct
@@ -89,9 +89,9 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
static int inet_pton(int af, const char *src, void *dst)
{
struct addrinfo hints, *res, *ressave;
struct addrinfo hints = {0};
struct addrinfo *res, *ressave;
hints = (struct addrinfo){0};
hints.ai_family = af;
if (getaddrinfo(src, NULL, &hints, &res) != 0)
@@ -117,7 +117,7 @@ static int inet_pton(int af, const char *src, void *dst)
static mrb_value
mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
{
struct addrinfo hints, *res0, *res;
struct addrinfo hints = {0}, *res0, *res;
mrb_value ai, ary, family, lastai, nodename, protocol, sa, service, socktype;
mrb_int flags;
int arena_idx, error;
@@ -148,7 +148,6 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Integer, or nil");
}
hints = (struct addrinfo){0};
hints.ai_flags = (int)flags;
if (mrb_integer_p(family)) {