mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
Fixed conversion warnings from clang
Plus some other details. (Option '-Wuninitialized' was removed from the makefile because it is already enabled by -Wall.)
This commit is contained in:
parent
10e931da82
commit
3cdd49c94a
2
lcode.c
2
lcode.c
@ -1439,7 +1439,7 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2,
|
||||
e1->u.info = pc;
|
||||
e1->k = VRELOC; /* all those operations are relocatable */
|
||||
luaK_fixline(fs, line);
|
||||
luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */
|
||||
luaK_codeABCk(fs, mmop, v1, v2, cast_int(event), flip); /* metamethod */
|
||||
luaK_fixline(fs, line);
|
||||
}
|
||||
|
||||
|
7
llex.c
7
llex.c
@ -349,9 +349,14 @@ static int readhexaesc (LexState *ls) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** When reading a UTF-8 escape sequence, save everything to the buffer
|
||||
** for error reporting in case of errors; 'i' counts the number of
|
||||
** saved characters, so that they can be removed if case of success.
|
||||
*/
|
||||
static unsigned long readutf8esc (LexState *ls) {
|
||||
unsigned long r;
|
||||
int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */
|
||||
int i = 4; /* number of chars to be removed: start with #"\u{X" */
|
||||
save_and_next(ls); /* skip 'u' */
|
||||
esccheck(ls, ls->current == '{', "missing '{'");
|
||||
r = cast_ulong(gethexa(ls)); /* must have at least one digit */
|
||||
|
4
lmem.h
4
lmem.h
@ -39,11 +39,11 @@
|
||||
** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that
|
||||
** the result is not larger than 'n' and cannot overflow a 'size_t'
|
||||
** when multiplied by the size of type 't'. (Assumes that 'n' is an
|
||||
** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.)
|
||||
** 'int' and that 'int' is not larger than 'size_t'.)
|
||||
*/
|
||||
#define luaM_limitN(n,t) \
|
||||
((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \
|
||||
cast_uint((MAX_SIZET/sizeof(t))))
|
||||
cast_int((MAX_SIZET/sizeof(t))))
|
||||
|
||||
|
||||
/*
|
||||
|
@ -194,6 +194,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
|
||||
|
||||
|
||||
lu_byte luaO_hexavalue (int c) {
|
||||
lua_assert(lisxdigit(c));
|
||||
if (lisdigit(c)) return cast_byte(c - '0');
|
||||
else return cast_byte((ltolower(c) - 'a') + 10);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ static int searchvar (FuncState *fs, TString *n, expdesc *var) {
|
||||
init_exp(var, VCONST, fs->firstlocal + i);
|
||||
else /* real variable */
|
||||
init_var(fs, var, i);
|
||||
return var->k;
|
||||
return cast_int(var->k);
|
||||
}
|
||||
}
|
||||
return -1; /* not found */
|
||||
|
4
ltable.c
4
ltable.c
@ -96,7 +96,7 @@ typedef union {
|
||||
** between 2^MAXHBITS and the maximum size such that, measured in bytes,
|
||||
** it fits in a 'size_t'.
|
||||
*/
|
||||
#define MAXHSIZE luaM_limitN(1u << MAXHBITS, Node)
|
||||
#define MAXHSIZE luaM_limitN(1 << MAXHBITS, Node)
|
||||
|
||||
|
||||
/*
|
||||
@ -598,7 +598,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned size) {
|
||||
else {
|
||||
int i;
|
||||
int lsize = luaO_ceillog2(size);
|
||||
if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE)
|
||||
if (lsize > MAXHBITS || (1 << lsize) > MAXHSIZE)
|
||||
luaG_runerror(L, "table overflow");
|
||||
size = twoto(lsize);
|
||||
if (lsize < LIMFORLAST) /* no 'lastfree' field? */
|
||||
|
1
makefile
1
makefile
@ -15,7 +15,6 @@ CWARNSCPP= \
|
||||
-Wdouble-promotion \
|
||||
-Wmissing-declarations \
|
||||
-Wconversion \
|
||||
-Wuninitialized \
|
||||
-Wstrict-overflow=2 \
|
||||
# the next warnings might be useful sometimes,
|
||||
# but usually they generate too much noise
|
||||
|
@ -3848,7 +3848,6 @@ or zero if the value at @id{idx} is not a number.
|
||||
|
||||
Calls a function (or a callable object) in protected mode.
|
||||
|
||||
|
||||
Both @id{nargs} and @id{nresults} have the same meaning as
|
||||
in @Lid{lua_call}.
|
||||
If there are no errors during the call,
|
||||
@ -3998,9 +3997,9 @@ Lua will call @id{falloc} before raising the error.
|
||||
Pushes onto the stack a formatted string
|
||||
and returns a pointer to this string @see{constchar}.
|
||||
The result is a copy of @id{fmt} with
|
||||
each @emph{conversion specifier} replaced by its respective
|
||||
extra argument.
|
||||
A conversion specifier can be
|
||||
each @emph{conversion specifier} replaced by a string representation
|
||||
of its respective extra argument.
|
||||
A conversion specifier (and its corresponding extra argument) can be
|
||||
@Char{%%} (inserts the character @Char{%}),
|
||||
@Char{%s} (inserts a zero-terminated string, with no size restrictions),
|
||||
@Char{%f} (inserts a @Lid{lua_Number}),
|
||||
|
@ -5,7 +5,7 @@ LUA_DIR = ../../
|
||||
CC = gcc
|
||||
|
||||
# compilation should generate Dynamic-Link Libraries
|
||||
CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared
|
||||
CFLAGS = -Wall -std=c99 -O2 -I$(LUA_DIR) -fPIC -shared
|
||||
|
||||
# libraries used by the tests
|
||||
all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so
|
||||
|
Loading…
x
Reference in New Issue
Block a user