Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c925b15

Browse files
committed
Silence warnings in MSVC++: hide unused variables, add constness back to
inet_pton/ntop, convert htons argument to u_short.
1 parent 20f51a7 commit c925b15

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

Modules/getaddrinfo.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ getaddrinfo(hostname, servname, hints, res)
343343
pai->ai_socktype = SOCK_DGRAM;
344344
pai->ai_protocol = IPPROTO_UDP;
345345
}
346-
port = htons(atoi(servname));
346+
port = htons((u_short)atoi(servname));
347347
} else {
348348
struct servent *sp;
349349
char *proto;
@@ -417,7 +417,9 @@ getaddrinfo(hostname, servname, hints, res)
417417
for (i = 0; gai_afdl[i].a_af; i++) {
418418
if (inet_pton(gai_afdl[i].a_af, hostname, pton)) {
419419
u_long v4a;
420+
#ifdef INET6
420421
u_char pfx;
422+
#endif
421423

422424
switch (gai_afdl[i].a_af) {
423425
case AF_INET:
@@ -492,7 +494,10 @@ get_name(addr, gai_afd, res, numaddr, pai, port0)
492494
u_short port = port0 & 0xffff;
493495
struct hostent *hp;
494496
struct addrinfo *cur;
495-
int error = 0, h_error;
497+
int error = 0;
498+
#ifdef INET6
499+
int h_error;
500+
#endif
496501

497502
#ifdef INET6
498503
hp = getipnodebyaddr(addr, gai_afd->a_addrlen, gai_afd->a_af, &h_error);

Modules/getnameinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
9898
int family, len, i;
9999
char *addr, *p;
100100
u_long v4a;
101+
#ifdef INET6
101102
u_char pfx;
103+
#endif
102104
int h_error;
103105
char numserv[512];
104106
char numaddr[512];

Modules/socketmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ Socket methods:
207207
#endif /* USE_SSL */
208208

209209
#ifndef HAVE_INET_PTON
210-
int inet_pton (int af, char *src, void *dst);
211-
char *inet_ntop(int af, void *src, char *dst, socklen_t size);
210+
int inet_pton (int af, const char *src, void *dst);
211+
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
212212
#endif
213213

214214
/* I know this is a bad practice, but it is the easiest... */
@@ -2948,7 +2948,7 @@ init_socket(void)
29482948
/* Simplistic emulation code for inet_pton that only works for IPv4 */
29492949
#ifndef HAVE_INET_PTON
29502950
int
2951-
inet_pton (int af, char *src, void *dst)
2951+
inet_pton (int af, const char *src, void *dst)
29522952
{
29532953
if(af == AF_INET){
29542954
long packed_addr;
@@ -2966,8 +2966,8 @@ inet_pton (int af, char *src, void *dst)
29662966
return -1;
29672967
}
29682968

2969-
char *
2970-
inet_ntop(int af, void *src, char *dst, socklen_t size)
2969+
const char *
2970+
inet_ntop(int af, const void *src, char *dst, socklen_t size)
29712971
{
29722972
if (af == AF_INET) {
29732973
struct in_addr packed_addr;

0 commit comments

Comments
 (0)