The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b728aaa12cbe92eb21e40231e81ac3b6b0b55c40

commit b728aaa12cbe92eb21e40231e81ac3b6b0b55c40
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-06-27 09:27:14 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-06-30 15:00:27 +0000

    pfctl: Simplify getaddrinfo() error handling
    
    `error' is not used so drop it and jump to the end.
    
    OK sashan
    
    Obtained from:  OpenBSD, kn <k...@openbsd.org>, da7f49d74e
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/pfctl_parser.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 92debd6227e7..c475eab0de91 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1968,8 +1968,7 @@ host_dns(const char *s, int v4mask, int v6mask, int 
numeric)
 {
        struct addrinfo          hints, *res0, *res;
        struct node_host        *n, *h = NULL;
-       int                      error, noalias = 0;
-       int                      got4 = 0, got6 = 0;
+       int                      noalias = 0, got4 = 0, got6 = 0;
        char                    *p, *ps;
 
        if ((ps = strdup(s)) == NULL)
@@ -1983,11 +1982,8 @@ host_dns(const char *s, int v4mask, int v6mask, int 
numeric)
        hints.ai_socktype = SOCK_STREAM; /* DUMMY */
        if (numeric)
                hints.ai_flags = AI_NUMERICHOST;
-       error = getaddrinfo(ps, NULL, &hints, &res0);
-       if (error) {
-               free(ps);
-               return (h);
-       }
+       if (getaddrinfo(ps, NULL, &hints, &res0) != 0)
+               goto error;
 
        for (res = res0; res; res = res->ai_next) {
                if (res->ai_family != AF_INET &&
@@ -2035,6 +2031,7 @@ host_dns(const char *s, int v4mask, int v6mask, int 
numeric)
                }
        }
        freeaddrinfo(res0);
+error:
        free(ps);
 
        return (h);

Reply via email to