The branch main has been updated by kp:

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

commit dd2d7ba6f338925af00883220a03d86c4e9d0307
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-06-27 12:43:54 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-07-02 07:40:53 +0000

    pfctl: Fix function name in error messages by using __func__
    
    Obtained from:  OpenBSD, kn <k...@openbsd.org>, 91a155f4b6
    Obtained from:  OpenBSD, kn <k...@openbsd.org>, f79f34e142
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/pfctl.c        | 22 +++++++++++-----------
 sbin/pfctl/pfctl_parser.c |  6 +++---
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 8b76b0c3fdfd..926c18ee5dbc 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -2252,8 +2252,8 @@ int
 pfctl_rules(int dev, char *filename, int opts, int optimize,
     char *anchorname, struct pfr_buffer *trans)
 {
-#define ERR(x) do { warn(x); goto _error; } while(0)
-#define ERRX(x) do { warnx(x); goto _error; } while(0)
+#define ERR(...) do { warn(__VA_ARGS__); goto _error; } while(0)
+#define ERRX(...) do { warnx(__VA_ARGS__); goto _error; } while(0)
 
        struct pfr_buffer       *t, buf;
        struct pfioc_altq        pa;
@@ -2288,10 +2288,10 @@ pfctl_rules(int dev, char *filename, int opts, int 
optimize,
        memset(&pf, 0, sizeof(pf));
        memset(&trs, 0, sizeof(trs));
        if ((path = calloc(1, MAXPATHLEN)) == NULL)
-               ERRX("pfctl_rules: calloc");
+               ERRX("%s: calloc", __func__);
        if (strlcpy(trs.pfrt_anchor, anchorname,
            sizeof(trs.pfrt_anchor)) >= sizeof(trs.pfrt_anchor))
-               ERRX("pfctl_rules: strlcpy");
+               ERRX("%s: strlcpy", __func__);
        pf.dev = dev;
        pf.h = pfh;
        pf.opts = opts;
@@ -2300,16 +2300,16 @@ pfctl_rules(int dev, char *filename, int opts, int 
optimize,
 
        /* non-brace anchor, create without resolving the path */
        if ((pf.anchor = calloc(1, sizeof(*pf.anchor))) == NULL)
-               ERRX("pfctl_rules: calloc");
+               ERRX("%s: calloc", __func__);
        rs = &pf.anchor->ruleset;
        pf_init_ruleset(rs);
        rs->anchor = pf.anchor;
        if (strlcpy(pf.anchor->path, anchorname,
            sizeof(pf.anchor->path)) >= sizeof(pf.anchor->path))
-               errx(1, "pfctl_rules: strlcpy");
+               errx(1, "%s: strlcpy", __func__);
        if (strlcpy(pf.anchor->name, anchorname,
            sizeof(pf.anchor->name)) >= sizeof(pf.anchor->name))
-               errx(1, "pfctl_rules: strlcpy");
+               errx(1, "%s: strlcpy", __func__);
 
 
        pf.astack[0] = pf.anchor;
@@ -2322,14 +2322,14 @@ pfctl_rules(int dev, char *filename, int opts, int 
optimize,
 
        /* Set up ethernet anchor */
        if ((pf.eanchor = calloc(1, sizeof(*pf.eanchor))) == NULL)
-               ERRX("pfctl_rules: calloc");
+               ERRX("%s: calloc", __func__);
 
        if (strlcpy(pf.eanchor->path, anchorname,
            sizeof(pf.eanchor->path)) >= sizeof(pf.eanchor->path))
-               errx(1, "pfctl_rules: strlcpy");
+               errx(1, "%s: strlcpy", __func__);
        if (strlcpy(pf.eanchor->name, anchorname,
            sizeof(pf.eanchor->name)) >= sizeof(pf.eanchor->name))
-               errx(1, "pfctl_rules: strlcpy");
+               errx(1, "%s: strlcpy", __func__);
 
        ethrs = &pf.eanchor->ruleset;
        pf_init_eth_ruleset(ethrs);
@@ -2343,7 +2343,7 @@ pfctl_rules(int dev, char *filename, int opts, int 
optimize,
                 * loaded at parse time.
                 */
                if (pfctl_ruleset_trans(&pf, anchorname, pf.anchor, true))
-                       ERRX("pfctl_rules");
+                       ERRX("%s", __func__);
                if (pf.loadopt & PFCTL_FLAG_ETH)
                        pf.eth_ticket = pfctl_get_ticket(t, PF_RULESET_ETH, 
anchorname);
                if (altqsupport && (pf.loadopt & PFCTL_FLAG_ALTQ))
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 871a18ca6c28..6b47d75f77f3 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1483,7 +1483,7 @@ ifa_load(void)
                                continue;
                n = calloc(1, sizeof(struct node_host));
                if (n == NULL)
-                       err(1, "address: calloc");
+                       err(1, "%s: calloc", __func__);
                n->af = ifa->ifa_addr->sa_family;
                n->ifa_flags = ifa->ifa_flags;
 #ifdef __KAME__
@@ -1540,7 +1540,7 @@ ifa_load(void)
                            ifa->ifa_addr)->sdl_index;
                }
                if ((n->ifname = strdup(ifa->ifa_name)) == NULL)
-                       err(1, "ifa_load: strdup");
+                       err(1, "%s: strdup", __func__);
                n->next = NULL;
                n->tail = n;
                if (h == NULL)
@@ -1743,7 +1743,7 @@ ifa_lookup(char *ifa_name, int flags)
                        got6 = 1;
                n = calloc(1, sizeof(struct node_host));
                if (n == NULL)
-                       err(1, "address: calloc");
+                       err(1, "%s: calloc", __func__);
                n->af = p->af;
                if (flags & PFI_AFLAG_BROADCAST)
                        memcpy(&n->addr.v.a.addr, &p->bcast,

Reply via email to