]> Kevux Git Server - fll/commitdiff
Bugfix: Incorrect documentation for f_network_from_ip_string().
authorKevin Day <Kevin@kevux.org>
Tue, 27 Jan 2026 02:49:06 +0000 (20:49 -0600)
committerKevin Day <Kevin@kevux.org>
Tue, 27 Jan 2026 02:49:06 +0000 (20:49 -0600)
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
level_0/f_network/c/network.h
level_0/f_network/data/documentation/man/man3/f_network_from_ip_string.3

index 96c8231b11d9acf1f34c70f911f1b367e2b78535..718ac28e49a7fa76b695d256f01c03f14438966f 100644 (file)
@@ -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_
 
index 17ffe56088ccb94d912f817277ab0e27df11aaff..8d08953753ba0cc5c14cee30a2e1369166e59db2 100644 (file)
@@ -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.
index 2a4805d6fd723ccaea8f1933f2328c220e4546c4..3dc80ddb957bca8ca424383d95f5d7cddc0f3021 100644 (file)
@@ -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 ""