From 6dca5e0a49bbb948d43d11305df4e6507e102936 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 7 Nov 2019 18:13:44 +0200 Subject: [PATCH] Fix couple warnings Alloc failure is already handled. --- src/nhlua.c | 13 +++++-------- sys/unix/hints/linux | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/nhlua.c b/src/nhlua.c index bdc09ba9d..47f8f23a8 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -551,10 +551,12 @@ char *defval; lua_getfield(L, -1, name); ret = luaL_optstring(L, -1, defval); - if (ret) - ret = dupstr(ret); + if (ret) { + lua_pop(L, 1); + return dupstr(ret); + } lua_pop(L, 1); - return ret; + return NULL; } int @@ -804,11 +806,6 @@ const char *fname; dlb_fseek(fh, 0L, SEEK_END); buflen = dlb_ftell(fh); buf = (char *) alloc(sizeof(char) * (buflen + 1)); - if (!buf) { - impossible("alloc: Error allocating %i bytes for loading lua file %s", buflen, fname); - ret = FALSE; - goto give_up; - } dlb_fseek(fh, 0L, SEEK_SET); do { diff --git a/sys/unix/hints/linux b/sys/unix/hints/linux index dcdee332d..391f4b9ae 100644 --- a/sys/unix/hints/linux +++ b/sys/unix/hints/linux @@ -34,6 +34,7 @@ CFLAGS+=-DCURSES_GRAPHICS #CFLAGS+=-DSCORE_ON_BOTL #CFLAGS+=-DMSGHANDLER #CFLAGS+=-DTTY_TILES_ESCCODES +CFLAGS+=-Wdiscarded-qualifiers -Wformat LINK=$(CC) # Only needed for GLIBC stack trace: