1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

raddrinfo.c: suppress warnings

* ext/socket/raddrinfo.c (numeric_getaddrinfo): move conditionally
  used variables inside the block, to suppress warnings on platforms
  where inet_pton() is not available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-02-23 01:29:25 +00:00
parent 7490f69117
commit 95be5381ec

View file

@ -176,19 +176,17 @@ numeric_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints, const struct addrinfo *hints,
struct addrinfo **res) struct addrinfo **res)
{ {
static const struct {
int socktype;
int protocol;
} list[] = {
{ SOCK_STREAM, IPPROTO_TCP },
{ SOCK_DGRAM, IPPROTO_UDP },
{ SOCK_RAW, 0 }
};
struct addrinfo *ai = NULL;
#ifdef HAVE_INET_PTON #ifdef HAVE_INET_PTON
if (node && (!service || strspn(service, "0123456789") == strlen(service))) { if (node && (!service || strspn(service, "0123456789") == strlen(service))) {
static const struct {
int socktype;
int protocol;
} list[] = {
{ SOCK_STREAM, IPPROTO_TCP },
{ SOCK_DGRAM, IPPROTO_UDP },
{ SOCK_RAW, 0 }
};
struct addrinfo *ai = NULL;
int port = service ? (unsigned short)atoi(service): 0; int port = service ? (unsigned short)atoi(service): 0;
int hint_family = hints ? hints->ai_family : PF_UNSPEC; int hint_family = hints ? hints->ai_family : PF_UNSPEC;
int hint_socktype = hints ? hints->ai_socktype : 0; int hint_socktype = hints ? hints->ai_socktype : 0;