Skip to content

Remove HAVE_INET_PTON #13410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 21, 2024
Merged

Remove HAVE_INET_PTON #13410

merged 11 commits into from
Feb 21, 2024

Conversation

jorgsowa
Copy link
Contributor

Analogical change to #12700

When inet_ntop is available then inet_pton also.

@jorgsowa jorgsowa force-pushed the remove_HAVE_INET_PTON branch from fe53851 to e7e7a25 Compare February 16, 2024 20:31
@petk
Copy link
Member

petk commented Feb 16, 2024

Thanks @jorgsowa, I think this is logical indeed, if inet_pton is universally available on the current systems. Then probably also these tests can be simplified in the SKIPIF sections:

  • ext/standard/tests/network/inet.phpt
  • ext/standard/tests/network/inet_ipv6.phpt

@jorgsowa
Copy link
Contributor Author

@petk Thanks for review. Tests adjusted

@petk
Copy link
Member

petk commented Feb 17, 2024

Perfect, thanks. I'm not sure if this would be too much for this PR, but probably also the inet_aton can be now completely made obsolete and can be removed together with the Windows implementation file(s). The inet_aton is deprecated anyway. If I'm not mistaken...

@devnexen
Copy link
Member

Perfect, thanks. I'm not sure if this would be too much for this PR, but probably also the inet_aton can be now completely made obsolete and can be removed together with the Windows implementation file(s). The inet_aton is deprecated anyway. If I'm not mistaken...

I m not objecting neither. If the OP does not want to go any further, it looks good already.

@jorgsowa
Copy link
Contributor Author

I'm not sure if this would be too much for this PR, but probably also the inet_aton can be now completely made obsolete and can be removed together with the Windows implementation file(s). The inet_aton is deprecated anyway. If I'm not mistaken...

No problem to me. I will cover it in the next PR. 🙂

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just minor NITs

@@ -157,7 +157,7 @@ PHP_FUNCTION(gethostbyaddr)
hostname = php_gethostbyaddr(addr);

if (hostname == NULL) {
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
#if defined(HAVE_IPV6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(HAVE_IPV6)
#ifdef HAVE_IPV6

@@ -172,7 +172,7 @@ PHP_FUNCTION(gethostbyaddr)
/* {{{ php_gethostbyaddr */
static zend_string *php_gethostbyaddr(char *ip)
{
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
#if defined(HAVE_IPV6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(HAVE_IPV6)
#ifdef HAVE_IPV6

Comment on lines 5 to 6
if(PHP_INT_SIZE != 4) { die('skip 32 bit only'); }
if(strtolower(substr(PHP_OS, 0, 3)) == 'aix') { die('skip not for AIX'); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: space after if

main/network.c Outdated
@@ -545,7 +541,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo

/* first, try interpreting the address as a numeric address */

#if HAVE_IPV6 && HAVE_INET_PTON
#if HAVE_IPV6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if HAVE_IPV6
#ifdef HAVE_IPV6

think it should always test definition

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I have a long-standing (very outdated PR (#5526) now) to try to enable -Wundef to check these sorts of issues at compile time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need help with this PR, @Girgias ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take it over, I was hitting some issue with YACC generating something that I couldn't check.

main/network.c Outdated
@@ -852,25 +844,21 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
union {
struct sockaddr common;
struct sockaddr_in in4;
#if HAVE_IPV6 && HAVE_INET_PTON
#if HAVE_IPV6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if HAVE_IPV6
#ifdef HAVE_IPV6

main/network.c Outdated
local_address_len = sizeof(struct sockaddr_in);
local_address.in4.sin_family = sa->sa_family;
local_address.in4.sin_port = htons(bindport);
memset(&(local_address.in4.sin_zero), 0, sizeof(local_address.in4.sin_zero));
}
}
#if HAVE_IPV6 && HAVE_INET_PTON
#if HAVE_IPV6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if HAVE_IPV6
#ifdef HAVE_IPV6

@@ -130,7 +130,7 @@
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))

#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
#if defined(HAVE_IPV6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(HAVE_IPV6)
#ifdef HAVE_IPV6

main/network.c Outdated
@@ -545,7 +541,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo

/* first, try interpreting the address as a numeric address */

#if HAVE_IPV6 && HAVE_INET_PTON
#if HAVE_IPV6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I have a long-standing (very outdated PR (#5526) now) to try to enable -Wundef to check these sorts of issues at compile time.

@jorgsowa
Copy link
Contributor Author

Thank you all for the reviews. If I should add something else then please let me know. Otherwise, I don't know who should I ask for approval and merge now.

@Girgias Girgias merged commit e630aac into php:master Feb 21, 2024
@jorgsowa jorgsowa deleted the remove_HAVE_INET_PTON branch August 7, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants