Skip to content

Commit 2d66562

Browse files
authored
Sync HAVE_IPV6 and HAVE_GETADDRINFO in #if/ifdef/defined (#14341)
Follow up of GH-5526 (-Wundef)
1 parent 5109cf1 commit 2d66562

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

ext/sockets/conversions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx)
12431243
to_zval_read_aggregation(msghdr_c, zv, descriptors, ctx);
12441244
}
12451245

1246-
#if defined(IPV6_PKTINFO) && HAVE_IPV6
1246+
#if defined(IPV6_PKTINFO) && defined(HAVE_IPV6)
12471247
/* CONVERSIONS for if_index */
12481248
static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context *ctx)
12491249
{

ext/sockets/sendrecvmsg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ static void init_ancillary_registry(void)
107107
key.cmsg_type = type; \
108108
zend_hash_str_update_mem(&ancillary_registry.ht, (char*)&key, sizeof(key), (void*)&entry, sizeof(entry))
109109

110-
#if defined(IPV6_PKTINFO) && HAVE_IPV6
110+
#if defined(IPV6_PKTINFO) && defined(HAVE_IPV6)
111111
PUT_ENTRY(sizeof(struct in6_pktinfo), 0, 0, from_zval_write_in6_pktinfo,
112112
to_zval_read_in6_pktinfo, IPPROTO_IPV6, IPV6_PKTINFO);
113113
#endif
114114

115-
#if defined(IPV6_HOPLIMIT) && HAVE_IPV6
115+
#if defined(IPV6_HOPLIMIT) && defined(HAVE_IPV6)
116116
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
117117
to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT);
118118
#endif
119119

120-
#if defined(IPV6_TCLASS) && HAVE_IPV6
120+
#if defined(IPV6_TCLASS) && defined(HAVE_IPV6)
121121
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
122122
to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS);
123123
#endif

ext/sockets/sockaddr_conv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern zend_result php_string_to_if_index(const char *val, unsigned *out);
1616
int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock) /* {{{ */
1717
{
1818
struct in6_addr tmp;
19-
#if HAVE_GETADDRINFO
19+
#ifdef HAVE_GETADDRINFO
2020
struct addrinfo hints;
2121
struct addrinfo *addrinfo = NULL;
2222
#endif
@@ -25,7 +25,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
2525
if (inet_pton(AF_INET6, string, &tmp)) {
2626
memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr));
2727
} else {
28-
#if HAVE_GETADDRINFO
28+
#ifdef HAVE_GETADDRINFO
2929

3030
memset(&hints, 0, sizeof(struct addrinfo));
3131
hints.ai_family = AF_INET6;

ext/sockets/sockets.stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@
16641664
const SOL_LOCAL = UNKNOWN;
16651665
#endif
16661666

1667-
#if (defined(IPV6_RECVPKTINFO) && HAVE_IPV6)
1667+
#if (defined(IPV6_RECVPKTINFO) && defined(HAVE_IPV6))
16681668
/**
16691669
* IPv6 ancillary data
16701670
* @var int
@@ -1677,7 +1677,7 @@
16771677
*/
16781678
const IPV6_PKTINFO = UNKNOWN;
16791679
#endif
1680-
#if (defined(IPV6_RECVHOPLIMIT) && HAVE_IPV6)
1680+
#if (defined(IPV6_RECVHOPLIMIT) && defined(HAVE_IPV6))
16811681
/**
16821682
* @var int
16831683
* @cvalue IPV6_RECVHOPLIMIT
@@ -1690,7 +1690,7 @@
16901690
const IPV6_HOPLIMIT = UNKNOWN;
16911691
#endif
16921692

1693-
#if (defined(IPV6_RECVTCLASS) && HAVE_IPV6)
1693+
#if (defined(IPV6_RECVTCLASS) && defined(HAVE_IPV6))
16941694
/**
16951695
* @var int
16961696
* @cvalue IPV6_RECVTCLASS

ext/sockets/sockets_arginfo.h

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main/network.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
8787
# define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT
8888
#endif
8989

90-
#if HAVE_GETADDRINFO
90+
#ifdef HAVE_GETADDRINFO
9191
#ifdef HAVE_GAI_STRERROR
9292
# define PHP_GAI_STRERROR(x) (gai_strerror(x))
9393
#else
@@ -150,7 +150,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
150150
{
151151
struct sockaddr **sap;
152152
int n;
153-
#if HAVE_GETADDRINFO
153+
#ifdef HAVE_GETADDRINFO
154154
# ifdef HAVE_IPV6
155155
static int ipv6_borked = -1; /* the way this is used *is* thread safe */
156156
# endif
@@ -163,7 +163,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
163163
if (host == NULL) {
164164
return 0;
165165
}
166-
#if HAVE_GETADDRINFO
166+
#ifdef HAVE_GETADDRINFO
167167
memset(&hints, '\0', sizeof(hints));
168168

169169
hints.ai_family = AF_INET; /* default to regular inet (see below) */
@@ -422,7 +422,7 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
422422
sa = *sal;
423423

424424
switch (sa->sa_family) {
425-
#if HAVE_GETADDRINFO && HAVE_IPV6
425+
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
426426
case AF_INET6:
427427
((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
428428
socklen = sizeof(struct sockaddr_in6);
@@ -566,7 +566,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo
566566

567567
/* copy the details from the first item */
568568
switch ((*psal)->sa_family) {
569-
#if HAVE_GETADDRINFO && HAVE_IPV6
569+
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
570570
case AF_INET6:
571571
*in6 = **(struct sockaddr_in6**)psal;
572572
in6->sin6_port = htons(port);
@@ -802,7 +802,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
802802
sa = *sal;
803803

804804
switch (sa->sa_family) {
805-
#if HAVE_GETADDRINFO && HAVE_IPV6
805+
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
806806
case AF_INET6:
807807
if (!bindto || strchr(bindto, ':')) {
808808
((struct sockaddr_in6 *)sa)->sin6_port = htons(port);

sapi/cli/php_cli_server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s
13021302
}
13031303

13041304
switch ((*p)->sa_family) {
1305-
#if HAVE_GETADDRINFO && HAVE_IPV6
1305+
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
13061306
case AF_INET6:
13071307
sa = pemalloc(sizeof(struct sockaddr_in6), 1);
13081308
*(struct sockaddr_in6 *)sa = *(struct sockaddr_in6 *)*p;
@@ -1348,7 +1348,7 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s
13481348
goto out;
13491349
}
13501350
switch (sa->sa_family) {
1351-
#if HAVE_GETADDRINFO && HAVE_IPV6
1351+
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
13521352
case AF_INET6:
13531353
*port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
13541354
break;

0 commit comments

Comments
 (0)