The branch main has been updated by kp:

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

commit 6ccd82f8deb5cff3e5c2ad4df594c60470062c08
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-06-24 11:51:35 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-06-27 14:55:17 +0000

    pfctl: clean up allocation warnings
    
    No need to mention which memory allocation entry point failed (malloc,
    calloc or strdup), we just need to log that we ran out of memory in a
    particular function.
    
    Recommended by florian@ and deraadt@
    
    ok benno@ henning@ tb@
    
    Obtained from:  OpenBSD, krw <k...@openbsd.org>, 6a3d55f939
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/parse.y | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 41f2d8dc70e7..39d5ba317653 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -7143,23 +7143,21 @@ pushfile(const char *name, int secret)
 
        if ((nfile = calloc(1, sizeof(struct file))) == NULL ||
            (nfile->name = strdup(name)) == NULL) {
-               if (nfile) {
-                       warn("strdup");
+               warn("%s", __func__);
+               if (nfile)
                        free(nfile);
-               } else
-                       warn("calloc");
                return (NULL);
        }
        if (TAILQ_FIRST(&files) == NULL && strcmp(nfile->name, "-") == 0) {
                nfile->stream = stdin;
                free(nfile->name);
                if ((nfile->name = strdup("stdin")) == NULL) {
-                       warn("strdup");
+                       warn("%s", __func__);
                        free(nfile);
                        return (NULL);
                }
        } else if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
-               warn("%s", nfile->name);
+               warn("%s: %s", __func__, nfile->name);
                free(nfile->name);
                free(nfile);
                return (NULL);
@@ -7174,7 +7172,7 @@ pushfile(const char *name, int secret)
        nfile->ungetsize = 16;
        nfile->ungetbuf = malloc(nfile->ungetsize);
        if (nfile->ungetbuf == NULL) {
-               warn("malloc");
+               warn("%s", __func__);
                fclose(nfile->stream);
                free(nfile->name);
                free(nfile);

Reply via email to