aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-14 16:24:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-14 16:24:46 -0300
commit3cdd49c94a8feed94853ba3a6adaa556fb34fd8d (patch)
tree1f552c966d1fb5f5c23e956e6d98679f02a558b3
parent10e931da82268a9d190c17a9bdb9b1a4b48c2947 (diff)
downloadlua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.tar.gz
lua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.tar.bz2
lua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.zip
Fixed conversion warnings from clang
Plus some other details. (Option '-Wuninitialized' was removed from the makefile because it is already enabled by -Wall.)
-rw-r--r--lcode.c2
-rw-r--r--llex.c7
-rw-r--r--lmem.h4
-rw-r--r--lobject.c1
-rw-r--r--lparser.c2
-rw-r--r--ltable.c4
-rw-r--r--makefile1
-rw-r--r--manual/manual.of7
-rw-r--r--testes/libs/makefile2
9 files changed, 17 insertions, 13 deletions
diff --git a/lcode.c b/lcode.c
index 641f0d09..8c04d8ab 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1439,7 +1439,7 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2,
1439 e1->u.info = pc; 1439 e1->u.info = pc;
1440 e1->k = VRELOC; /* all those operations are relocatable */ 1440 e1->k = VRELOC; /* all those operations are relocatable */
1441 luaK_fixline(fs, line); 1441 luaK_fixline(fs, line);
1442 luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ 1442 luaK_codeABCk(fs, mmop, v1, v2, cast_int(event), flip); /* metamethod */
1443 luaK_fixline(fs, line); 1443 luaK_fixline(fs, line);
1444} 1444}
1445 1445
diff --git a/llex.c b/llex.c
index 3518f0da..1c4227ca 100644
--- a/llex.c
+++ b/llex.c
@@ -349,9 +349,14 @@ static int readhexaesc (LexState *ls) {
349} 349}
350 350
351 351
352/*
353** When reading a UTF-8 escape sequence, save everything to the buffer
354** for error reporting in case of errors; 'i' counts the number of
355** saved characters, so that they can be removed if case of success.
356*/
352static unsigned long readutf8esc (LexState *ls) { 357static unsigned long readutf8esc (LexState *ls) {
353 unsigned long r; 358 unsigned long r;
354 int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ 359 int i = 4; /* number of chars to be removed: start with #"\u{X" */
355 save_and_next(ls); /* skip 'u' */ 360 save_and_next(ls); /* skip 'u' */
356 esccheck(ls, ls->current == '{', "missing '{'"); 361 esccheck(ls, ls->current == '{', "missing '{'");
357 r = cast_ulong(gethexa(ls)); /* must have at least one digit */ 362 r = cast_ulong(gethexa(ls)); /* must have at least one digit */
diff --git a/lmem.h b/lmem.h
index 204ce3bc..08358592 100644
--- a/lmem.h
+++ b/lmem.h
@@ -39,11 +39,11 @@
39** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that 39** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that
40** the result is not larger than 'n' and cannot overflow a 'size_t' 40** the result is not larger than 'n' and cannot overflow a 'size_t'
41** when multiplied by the size of type 't'. (Assumes that 'n' is an 41** when multiplied by the size of type 't'. (Assumes that 'n' is an
42** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) 42** 'int' and that 'int' is not larger than 'size_t'.)
43*/ 43*/
44#define luaM_limitN(n,t) \ 44#define luaM_limitN(n,t) \
45 ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ 45 ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \
46 cast_uint((MAX_SIZET/sizeof(t)))) 46 cast_int((MAX_SIZET/sizeof(t))))
47 47
48 48
49/* 49/*
diff --git a/lobject.c b/lobject.c
index 97dacaf5..c0fd182f 100644
--- a/lobject.c
+++ b/lobject.c
@@ -194,6 +194,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
194 194
195 195
196lu_byte luaO_hexavalue (int c) { 196lu_byte luaO_hexavalue (int c) {
197 lua_assert(lisxdigit(c));
197 if (lisdigit(c)) return cast_byte(c - '0'); 198 if (lisdigit(c)) return cast_byte(c - '0');
198 else return cast_byte((ltolower(c) - 'a') + 10); 199 else return cast_byte((ltolower(c) - 'a') + 10);
199} 200}
diff --git a/lparser.c b/lparser.c
index 83e341ed..380e45f5 100644
--- a/lparser.c
+++ b/lparser.c
@@ -405,7 +405,7 @@ static int searchvar (FuncState *fs, TString *n, expdesc *var) {
405 init_exp(var, VCONST, fs->firstlocal + i); 405 init_exp(var, VCONST, fs->firstlocal + i);
406 else /* real variable */ 406 else /* real variable */
407 init_var(fs, var, i); 407 init_var(fs, var, i);
408 return var->k; 408 return cast_int(var->k);
409 } 409 }
410 } 410 }
411 return -1; /* not found */ 411 return -1; /* not found */
diff --git a/ltable.c b/ltable.c
index b6b1fa1a..122b7f17 100644
--- a/ltable.c
+++ b/ltable.c
@@ -96,7 +96,7 @@ typedef union {
96** between 2^MAXHBITS and the maximum size such that, measured in bytes, 96** between 2^MAXHBITS and the maximum size such that, measured in bytes,
97** it fits in a 'size_t'. 97** it fits in a 'size_t'.
98*/ 98*/
99#define MAXHSIZE luaM_limitN(1u << MAXHBITS, Node) 99#define MAXHSIZE luaM_limitN(1 << MAXHBITS, Node)
100 100
101 101
102/* 102/*
@@ -598,7 +598,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned size) {
598 else { 598 else {
599 int i; 599 int i;
600 int lsize = luaO_ceillog2(size); 600 int lsize = luaO_ceillog2(size);
601 if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE) 601 if (lsize > MAXHBITS || (1 << lsize) > MAXHSIZE)
602 luaG_runerror(L, "table overflow"); 602 luaG_runerror(L, "table overflow");
603 size = twoto(lsize); 603 size = twoto(lsize);
604 if (lsize < LIMFORLAST) /* no 'lastfree' field? */ 604 if (lsize < LIMFORLAST) /* no 'lastfree' field? */
diff --git a/makefile b/makefile
index 64dee501..8506e93c 100644
--- a/makefile
+++ b/makefile
@@ -15,7 +15,6 @@ CWARNSCPP= \
15 -Wdouble-promotion \ 15 -Wdouble-promotion \
16 -Wmissing-declarations \ 16 -Wmissing-declarations \
17 -Wconversion \ 17 -Wconversion \
18 -Wuninitialized \
19 -Wstrict-overflow=2 \ 18 -Wstrict-overflow=2 \
20 # the next warnings might be useful sometimes, 19 # the next warnings might be useful sometimes,
21 # but usually they generate too much noise 20 # but usually they generate too much noise
diff --git a/manual/manual.of b/manual/manual.of
index bb95148a..77e37de3 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -3848,7 +3848,6 @@ or zero if the value at @id{idx} is not a number.
3848 3848
3849Calls a function (or a callable object) in protected mode. 3849Calls a function (or a callable object) in protected mode.
3850 3850
3851
3852Both @id{nargs} and @id{nresults} have the same meaning as 3851Both @id{nargs} and @id{nresults} have the same meaning as
3853in @Lid{lua_call}. 3852in @Lid{lua_call}.
3854If there are no errors during the call, 3853If there are no errors during the call,
@@ -3998,9 +3997,9 @@ Lua will call @id{falloc} before raising the error.
3998Pushes onto the stack a formatted string 3997Pushes onto the stack a formatted string
3999and returns a pointer to this string @see{constchar}. 3998and returns a pointer to this string @see{constchar}.
4000The result is a copy of @id{fmt} with 3999The result is a copy of @id{fmt} with
4001each @emph{conversion specifier} replaced by its respective 4000each @emph{conversion specifier} replaced by a string representation
4002extra argument. 4001of its respective extra argument.
4003A conversion specifier can be 4002A conversion specifier (and its corresponding extra argument) can be
4004@Char{%%} (inserts the character @Char{%}), 4003@Char{%%} (inserts the character @Char{%}),
4005@Char{%s} (inserts a zero-terminated string, with no size restrictions), 4004@Char{%s} (inserts a zero-terminated string, with no size restrictions),
4006@Char{%f} (inserts a @Lid{lua_Number}), 4005@Char{%f} (inserts a @Lid{lua_Number}),
diff --git a/testes/libs/makefile b/testes/libs/makefile
index 9c0c4e3f..4e7f965e 100644
--- a/testes/libs/makefile
+++ b/testes/libs/makefile
@@ -5,7 +5,7 @@ LUA_DIR = ../../
5CC = gcc 5CC = gcc
6 6
7# compilation should generate Dynamic-Link Libraries 7# compilation should generate Dynamic-Link Libraries
8CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared 8CFLAGS = -Wall -std=c99 -O2 -I$(LUA_DIR) -fPIC -shared
9 9
10# libraries used by the tests 10# libraries used by the tests
11all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so 11all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so