The branch main has been updated by kevans:

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

commit b41b6fdb3a1635de4c2a9280aab12b83e3aeffc5
Author:     Kyle Evans <[email protected]>
AuthorDate: 2026-01-28 15:37:04 +0000
Commit:     Kyle Evans <[email protected]>
CommitDate: 2026-01-28 15:43:14 +0000

    flua: lposix: fix WARNS=6 issues
    
    lposix is the last holdout of modules built into flua until we can fix
    the module design to have the right parts require()able.  Address a
    valid bug in lua_read() found at a higher WARNS and drop the override
    entirely.  Some of the modules could possibly be re-evaluated.
    
    Fixes:  c2caf3b3313 ("flua: lposix: add more useful functions [...]")
    Reported by:    des
    Reviewed by:    des
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
---
 libexec/flua/Makefile         |  1 -
 libexec/flua/modules/lposix.c | 12 ++++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libexec/flua/Makefile b/libexec/flua/Makefile
index f1c46b270ded..c40328d37963 100644
--- a/libexec/flua/Makefile
+++ b/libexec/flua/Makefile
@@ -44,7 +44,6 @@ LUASRC?=      ${SRCTOP}/contrib/lua/src
 .PATH: ${LUASRC}
 
 PROG=  flua
-WARNS?=        3
 
 CWARNFLAGS.gcc+=       -Wno-format-nonliteral
 
diff --git a/libexec/flua/modules/lposix.c b/libexec/flua/modules/lposix.c
index 75cdd345aeaa..a25e875045a2 100644
--- a/libexec/flua/modules/lposix.c
+++ b/libexec/flua/modules/lposix.c
@@ -8,6 +8,7 @@
 #include <sys/utsname.h>
 #include <sys/wait.h>
 
+#include <assert.h>
 #include <errno.h>
 #include <fnmatch.h>
 #include <grp.h>
@@ -254,7 +255,7 @@ lua_execp(lua_State *L)
        }
        argv[argc + 1] = NULL;
 
-       execvp(file, (char **)argv);
+       execvp(file, __DECONST(char **, argv));
        error = errno;
 
        lua_pushnil(L);
@@ -386,7 +387,7 @@ lua_read(lua_State *L)
        char *buf;
        ssize_t ret;
        size_t sz;
-       int error, fd;
+       int error = 0, fd;
 
        enforce_max_args(L, 2);
        fd = luaL_checkinteger(L, 1);
@@ -398,8 +399,10 @@ lua_read(lua_State *L)
        }
 
        buf = malloc(sz);
-       if (buf == NULL)
+       if (buf == NULL) {
+               error = errno;
                goto err;
+       }
 
        /*
         * For 0-byte reads, we'll still push the empty string and let the
@@ -412,12 +415,13 @@ lua_read(lua_State *L)
                error = errno; /* Save to avoid clobber by free() */
 
        free(buf);
-       if (error != 0)
+       if (ret < 0)
                goto err;
 
        /* Just the string pushed. */
        return (1);
 err:
+       assert(error != 0);
        lua_pushnil(L);
        lua_pushstring(L, strerror(error));
        lua_pushinteger(L, error);

Reply via email to