From abd167c465e5848a3e18fb9b77d0b69c2553a7de Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 26 Jan 2026 20:49:06 -0600 Subject: [PATCH] Bugfix: Incorrect documentation for f_network_from_ip_string(). The `f_network_from_ip_string()` is incorrectly referencing IPv6 bracket notation. Make it clear that ports are not supported. Make it clear that IPv6 bracket notation is not supported. Clean up the `f_network_from_ip_string()`, removing unnecessary nesting. --- level_0/f_network/c/network.c | 19 +++++++------------ level_0/f_network/c/network.h | 6 ++++-- .../man/man3/f_network_from_ip_string.3 | 6 +++--- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/level_0/f_network/c/network.c b/level_0/f_network/c/network.c index 96c8231b1..718ac28e4 100644 --- a/level_0/f_network/c/network.c +++ b/level_0/f_network/c/network.c @@ -92,22 +92,17 @@ extern "C" { if (!from.used || to->type == f_network_family_none_e) return F_data_not; - { - const int result = (to->type == f_network_family_ip_4_e) - ? inet_pton(AF_INET, from.string, (void *) & to->address.v4) - : inet_pton(AF_INET6, from.string, (void *) & to->address.v6); + const int result = (to->type == f_network_family_ip_4_e) + ? inet_pton(AF_INET, from.string, (void *) & to->address.v4) + : inet_pton(AF_INET6, from.string, (void *) & to->address.v6); - if (result == -1) { - if (errno == EAFNOSUPPORT) return F_status_set_error(F_support_not); + if (result == -1) { + if (errno == EAFNOSUPPORT) return F_status_set_error(F_support_not); - return F_status_set_error(F_failure); - } - else if (result) { - return F_okay; - } + return F_status_set_error(F_failure); } - return F_status_set_error(F_address_not); + return result ? F_okay : F_status_set_error(F_address_not); } #endif // _di_f_network_from_ip_string_ diff --git a/level_0/f_network/c/network.h b/level_0/f_network/c/network.h index 17ffe5608..8d0895375 100644 --- a/level_0/f_network/c/network.h +++ b/level_0/f_network/c/network.h @@ -131,12 +131,14 @@ extern "C" { * Convert from a human-friendly string representing the IP address digit into a network IP address digit. * * This is for the IP address and is not for the Domain Name. + * This does not get the port number and passed address must neither contain the port number nor IPv6 address brackets. * * @param from - * The human-friendly IP address string. + * The human-friendly IP version 4 or version 6 family address string. + * + * This must be a NULL terminated string. * @param to * The converted IP version 4 or version 6 family integer. - * For IPv6, the use of a port number requires the address to be encases in brackets, like: [::1]:80. * * @return * F_okay on success. diff --git a/level_0/f_network/data/documentation/man/man3/f_network_from_ip_string.3 b/level_0/f_network/data/documentation/man/man3/f_network_from_ip_string.3 index 2a4805d6f..3dc80ddb9 100644 --- a/level_0/f_network/data/documentation/man/man3/f_network_from_ip_string.3 +++ b/level_0/f_network/data/documentation/man/man3/f_network_from_ip_string.3 @@ -14,17 +14,17 @@ f_network_from_ip_string \- .PP Convert from a human-friendly string representing the IP address digit into a network IP address digit. .PP -This is for the IP address and is not for the Domain Name. +This is for the IP address and is not for the Domain Name. This does not get the port number and from string must neither contain the port number nor IPv6 address brackets. .PP F_address_not (with error bit) if from is not a valid address. F_parameter (with error bit) if a parameter is invalid. F_space_not (with error bit) if not enough space is available in to.string. F_support_not (with error bit) if an invalid address family type is passed to inet_pton(). F_failure (with error bit) on any other error. .SH PARAMETERS .TP .B from -The human-friendly IP address string. +The human-friendly IP version 4 or version 6 family address string. This must be a NULL terminated string. .TP .B to -The converted IP version 4 or version 6 family integer. For IPv6, the use of a port number requires the address to be encases in brackets, like: [::1]:80. +The converted IP version 4 or version 6 family integer. .SH STRUCTURES .SS "" -- 2.47.3