From b41b6fdb3a1635de4c2a9280aab12b83e3aeffc5 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 28 Jan 2026 09:37:04 -0600 Subject: 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/modules/lposix.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libexec/flua/modules') 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 #include +#include #include #include #include @@ -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); -- cgit v1.3