Fixed conversion warnings from clang · lua/lua@3cdd49c · GitHub
Skip to content

Commit 3cdd49c

Browse files
committed
Fixed conversion warnings from clang
Plus some other details. (Option '-Wuninitialized' was removed from the makefile because it is already enabled by -Wall.)
1 parent 10e931d commit 3cdd49c

9 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎lcode.c‎

Lines changed: 1 addition & 1 deletion

‎llex.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,14 @@ static int readhexaesc (LexState *ls) {
349349
}
350350

351351

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+
*/
352357
static unsigned long readutf8esc (LexState *ls) {
353358
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" */
355360
save_and_next(ls); /* skip 'u' */
356361
esccheck(ls, ls->current == '{', "missing '{'");
357362
r = cast_ulong(gethexa(ls)); /* must have at least one digit */

‎lmem.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that
4040
** the result is not larger than 'n' and cannot overflow a 'size_t'
4141
** 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'.)
4343
*/
4444
#define luaM_limitN(n,t) \
4545
((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \
46-
cast_uint((MAX_SIZET/sizeof(t))))
46+
cast_int((MAX_SIZET/sizeof(t))))
4747

4848

4949
/*

‎lobject.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
194194

195195

196196
lu_byte luaO_hexavalue (int c) {
197+
lua_assert(lisxdigit(c));
197198
if (lisdigit(c)) return cast_byte(c - '0');
198199
else return cast_byte((ltolower(c) - 'a') + 10);
199200
}

‎lparser.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static int searchvar (FuncState *fs, TString *n, expdesc *var) {
405405
init_exp(var, VCONST, fs->firstlocal + i);
406406
else /* real variable */
407407
init_var(fs, var, i);
408-
return var->k;
408+
return cast_int(var->k);
409409
}
410410
}
411411
return -1; /* not found */

‎ltable.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ typedef union {
9696
** between 2^MAXHBITS and the maximum size such that, measured in bytes,
9797
** it fits in a 'size_t'.
9898
*/
99-
#define MAXHSIZE luaM_limitN(1u << MAXHBITS, Node)
99+
#define MAXHSIZE luaM_limitN(1 << MAXHBITS, Node)
100100

101101

102102
/*
@@ -598,7 +598,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned size) {
598598
else {
599599
int i;
600600
int lsize = luaO_ceillog2(size);
601-
if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE)
601+
if (lsize > MAXHBITS || (1 << lsize) > MAXHSIZE)
602602
luaG_runerror(L, "table overflow");
603603
size = twoto(lsize);
604604
if (lsize < LIMFORLAST) /* no 'lastfree' field? */

‎makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ CWARNSCPP= \
1515
-Wdouble-promotion \
1616
-Wmissing-declarations \
1717
-Wconversion \
18-
-Wuninitialized \
1918
-Wstrict-overflow=2 \
2019
# the next warnings might be useful sometimes,
2120
# but usually they generate too much noise

‎manual/manual.of‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,7 +3848,6 @@ or zero if the value at @id{idx} is not a number.
38483848

38493849
Calls a function (or a callable object) in protected mode.
38503850

3851-
38523851
Both @id{nargs} and @id{nresults} have the same meaning as
38533852
in @Lid{lua_call}.
38543853
If there are no errors during the call,
@@ -3998,9 +3997,9 @@ Lua will call @id{falloc} before raising the error.
39983997
Pushes onto the stack a formatted string
39993998
and returns a pointer to this string @see{constchar}.
40003999
The result is a copy of @id{fmt} with
4001-
each @emph{conversion specifier} replaced by its respective
4002-
extra argument.
4003-
A conversion specifier can be
4000+
each @emph{conversion specifier} replaced by a string representation
4001+
of its respective extra argument.
4002+
A conversion specifier (and its corresponding extra argument) can be
40044003
@Char{%%} (inserts the character @Char{%}),
40054004
@Char{%s} (inserts a zero-terminated string, with no size restrictions),
40064005
@Char{%f} (inserts a @Lid{lua_Number}),

‎testes/libs/makefile‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)