aboutsummaryrefslogtreecommitdiffstats
path: root/module/lua
diff options
context:
space:
mode:
Diffstat (limited to 'module/lua')
-rw-r--r--module/lua/lapi.c2
-rw-r--r--module/lua/lcompat.c4
-rw-r--r--module/lua/lctype.h2
-rw-r--r--module/lua/llex.c2
-rw-r--r--module/lua/lobject.c2
-rw-r--r--module/lua/lparser.c2
-rw-r--r--module/lua/lstring.c6
-rw-r--r--module/lua/ltable.c2
-rw-r--r--module/lua/ltable.h2
9 files changed, 14 insertions, 10 deletions
diff --git a/module/lua/lapi.c b/module/lua/lapi.c
index c8b49dc63..54c74d38e 100644
--- a/module/lua/lapi.c
+++ b/module/lua/lapi.c
@@ -424,7 +424,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
LUA_API void *lua_touserdata (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
switch (ttypenv(o)) {
- case LUA_TUSERDATA: return (rawuvalue(o) + 1);
+ case LUA_TUSERDATA: return ((void *)(rawuvalue(o) + 1));
case LUA_TLIGHTUSERDATA: return pvalue(o);
default: return NULL;
}
diff --git a/module/lua/lcompat.c b/module/lua/lcompat.c
index 3fa2e664c..c0a27182c 100644
--- a/module/lua/lcompat.c
+++ b/module/lua/lcompat.c
@@ -6,13 +6,13 @@
ssize_t
-lcompat_sprintf(char *buf, const char *fmt, ...)
+lcompat_sprintf(char *buf, size_t size, const char *fmt, ...)
{
ssize_t res;
va_list args;
va_start(args, fmt);
- res = vsnprintf(buf, INT_MAX, fmt, args);
+ res = vsnprintf(buf, size, fmt, args);
va_end(args);
return (res);
diff --git a/module/lua/lctype.h b/module/lua/lctype.h
index b53d88370..b16b6bc7d 100644
--- a/module/lua/lctype.h
+++ b/module/lua/lctype.h
@@ -48,7 +48,7 @@
/*
** add 1 to char to allow index -1 (EOZ)
*/
-#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
+#define testprop(c,p) (luai_ctype_[(lu_byte)(c)+1] & (p))
/*
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
diff --git a/module/lua/llex.c b/module/lua/llex.c
index a7144681c..e98d74320 100644
--- a/module/lua/llex.c
+++ b/module/lua/llex.c
@@ -235,7 +235,7 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) {
expo = "Pp";
for (;;) {
if (check_next(ls, expo)) /* exponent part? */
- check_next(ls, "+-"); /* optional exponent sign */
+ (void) check_next(ls, "+-"); /* optional exponent sign */
if (lisxdigit(ls->current) || ls->current == '.')
save_and_next(ls);
else break;
diff --git a/module/lua/lobject.c b/module/lua/lobject.c
index 7c0b3133a..024d3199f 100644
--- a/module/lua/lobject.c
+++ b/module/lua/lobject.c
@@ -201,7 +201,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
}
case 'p': {
char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
- int l = lcompat_sprintf(buff, "%p", va_arg(argp, void *));
+ int l = lcompat_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *));
pushstr(L, buff, l);
break;
}
diff --git a/module/lua/lparser.c b/module/lua/lparser.c
index 775e6ed25..e1dd88f2f 100644
--- a/module/lua/lparser.c
+++ b/module/lua/lparser.c
@@ -1527,7 +1527,7 @@ static void retstat (LexState *ls) {
}
}
luaK_ret(fs, first, nret);
- testnext(ls, ';'); /* skip optional semicolon */
+ (void) testnext(ls, ';'); /* skip optional semicolon */
}
diff --git a/module/lua/lstring.c b/module/lua/lstring.c
index 2903d2b75..7fcef3d88 100644
--- a/module/lua/lstring.c
+++ b/module/lua/lstring.c
@@ -97,14 +97,16 @@ void luaS_resize (lua_State *L, int newsize) {
static TString *createstrobj (lua_State *L, const char *str, size_t l,
int tag, unsigned int h, GCObject **list) {
TString *ts;
+ char *sbuf;
size_t totalsize; /* total size of TString object */
totalsize = sizeof(TString) + ((l + 1) * sizeof(char));
ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts;
ts->tsv.len = l;
ts->tsv.hash = h;
ts->tsv.extra = 0;
- memcpy(ts+1, str, l*sizeof(char));
- ((char *)(ts+1))[l] = '\0'; /* ending 0 */
+ sbuf = (char *)(TString *)(ts + 1);
+ memcpy(sbuf, str, l*sizeof(char));
+ sbuf[l] = '\0'; /* ending 0 */
return ts;
}
diff --git a/module/lua/ltable.c b/module/lua/ltable.c
index 73e1c2541..ea5a43c78 100644
--- a/module/lua/ltable.c
+++ b/module/lua/ltable.c
@@ -405,8 +405,10 @@ static Node *getfreepos (Table *t) {
TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
Node *mp;
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+#if defined LUA_HAS_FLOAT_NUMBERS
else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
luaG_runerror(L, "table index is NaN");
+#endif
mp = mainposition(t, key);
if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
Node *othern;
diff --git a/module/lua/ltable.h b/module/lua/ltable.h
index 212500011..ea877ebf4 100644
--- a/module/lua/ltable.h
+++ b/module/lua/ltable.h
@@ -11,7 +11,7 @@
#include "lobject.h"
-#define gnode(t,i) (&(t)->node[i])
+#define gnode(t,i) ((Node *)&(t)->node[i])
#define gkey(n) (&(n)->i_key.tvk)
#define gval(n) (&(n)->i_val)
#define gnext(n) ((n)->i_key.nk.next)