From 01f011faebb68a079a4fa16478d3b0d992b3bd3e Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 12 Jun 2025 08:42:18 +0200 Subject: [PATCH] BUILD: hlua: Fix warnings about uninitialized variables In hlua_applet_tcp_recv_try() and hlua_applet_tcp_getline_yield(), GCC 14.2 reports warnings about 'blk2' variable that may be used uninitialized. It is a bit strange because the code is pretty similar than before. But to make it happy and to avoid bugs if the API change in future, 'blk2' is now used only when its length is greater than 0. No need to backport. --- src/hlua.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index b1c2fa4df..87e54f343 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5327,7 +5327,8 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC /* don't check the max length read and don't check. */ luaL_addlstring(&luactx->b, blk1, len1); - luaL_addlstring(&luactx->b, blk2, len2); + if (len2) + luaL_addlstring(&luactx->b, blk2, len2); applet_skip_input(luactx->appctx, len1+len2); luaL_pushresult(&luactx->b); @@ -5391,7 +5392,8 @@ __LJMP static int hlua_applet_tcp_recv_try(lua_State *L) * the end of data stream. */ luaL_addlstring(&luactx->b, blk1, len1); - luaL_addlstring(&luactx->b, blk2, len2); + if (len2) + luaL_addlstring(&luactx->b, blk2, len2); applet_skip_input(luactx->appctx, len1+len2); if (tick_is_expired(exp_date, now_ms)) { @@ -5414,7 +5416,8 @@ __LJMP static int hlua_applet_tcp_recv_try(lua_State *L) /* Copy the second block. */ if (len2 > len) len2 = len; - luaL_addlstring(&luactx->b, blk2, len2); + if (len2) + luaL_addlstring(&luactx->b, blk2, len2); len -= len2; applet_skip_input(luactx->appctx, len1+len2);