aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-27 13:32:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-27 13:32:59 -0300
commit0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b (patch)
tree0ac634fed90877130b1f102bf4075af999de2158 /lapi.c
parent15231d4fb2f6984b25e0353ff46eda1a180b686d (diff)
downloadlua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.tar.gz
lua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.tar.bz2
lua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.zip
Added gcc option '-Wconversion'
No warnings for standard numerical types. Still pending alternative numerical types.
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lapi.c b/lapi.c
index a9ab1d08..1f4e9f96 100644
--- a/lapi.c
+++ b/lapi.c
@@ -58,7 +58,7 @@ static void advancegc (lua_State *L, size_t delta) {
58 delta >>= 5; /* one object for each 32 bytes (empirical) */ 58 delta >>= 5; /* one object for each 32 bytes (empirical) */
59 if (delta > 0) { 59 if (delta > 0) {
60 global_State *g = G(L); 60 global_State *g = G(L);
61 luaE_setdebt(g, g->GCdebt - delta); 61 luaE_setdebt(g, g->GCdebt - cast(l_obj, delta));
62 } 62 }
63} 63}
64 64
@@ -437,9 +437,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
437LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { 437LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) {
438 const TValue *o = index2value(L, idx); 438 const TValue *o = index2value(L, idx);
439 switch (ttypetag(o)) { 439 switch (ttypetag(o)) {
440 case LUA_VSHRSTR: return tsvalue(o)->shrlen; 440 case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen);
441 case LUA_VLNGSTR: return tsvalue(o)->u.lnglen; 441 case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen);
442 case LUA_VUSERDATA: return uvalue(o)->len; 442 case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len);
443 case LUA_VTABLE: return luaH_getn(hvalue(o)); 443 case LUA_VTABLE: return luaH_getn(hvalue(o));
444 default: return 0; 444 default: return 0;
445 } 445 }
@@ -667,7 +667,7 @@ LUA_API int lua_pushthread (lua_State *L) {
667 667
668 668
669static int auxgetstr (lua_State *L, const TValue *t, const char *k) { 669static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
670 int tag; 670 lu_byte tag;
671 TString *str = luaS_new(L, k); 671 TString *str = luaS_new(L, k);
672 luaV_fastget(t, str, s2v(L->top.p), luaH_getstr, tag); 672 luaV_fastget(t, str, s2v(L->top.p), luaH_getstr, tag);
673 if (!tagisempty(tag)) { 673 if (!tagisempty(tag)) {
@@ -685,7 +685,7 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
685 685
686static void getGlobalTable (lua_State *L, TValue *gt) { 686static void getGlobalTable (lua_State *L, TValue *gt) {
687 Table *registry = hvalue(&G(L)->l_registry); 687 Table *registry = hvalue(&G(L)->l_registry);
688 int tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt); 688 lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt);
689 (void)tag; /* avoid not-used warnings when checks are off */ 689 (void)tag; /* avoid not-used warnings when checks are off */
690 api_check(L, novariant(tag) == LUA_TTABLE, "global table must exist"); 690 api_check(L, novariant(tag) == LUA_TTABLE, "global table must exist");
691} 691}
@@ -700,7 +700,7 @@ LUA_API int lua_getglobal (lua_State *L, const char *name) {
700 700
701 701
702LUA_API int lua_gettable (lua_State *L, int idx) { 702LUA_API int lua_gettable (lua_State *L, int idx) {
703 int tag; 703 lu_byte tag;
704 TValue *t; 704 TValue *t;
705 lua_lock(L); 705 lua_lock(L);
706 api_checkpop(L, 1); 706 api_checkpop(L, 1);
@@ -721,7 +721,7 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
721 721
722LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { 722LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
723 TValue *t; 723 TValue *t;
724 int tag; 724 lu_byte tag;
725 lua_lock(L); 725 lua_lock(L);
726 t = index2value(L, idx); 726 t = index2value(L, idx);
727 luaV_fastgeti(t, n, s2v(L->top.p), tag); 727 luaV_fastgeti(t, n, s2v(L->top.p), tag);
@@ -736,7 +736,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
736} 736}
737 737
738 738
739static int finishrawget (lua_State *L, int tag) { 739static int finishrawget (lua_State *L, lu_byte tag) {
740 if (tagisempty(tag)) /* avoid copying empty items to the stack */ 740 if (tagisempty(tag)) /* avoid copying empty items to the stack */
741 setnilvalue(s2v(L->top.p)); 741 setnilvalue(s2v(L->top.p));
742 api_incr_top(L); 742 api_incr_top(L);
@@ -754,7 +754,7 @@ l_sinline Table *gettable (lua_State *L, int idx) {
754 754
755LUA_API int lua_rawget (lua_State *L, int idx) { 755LUA_API int lua_rawget (lua_State *L, int idx) {
756 Table *t; 756 Table *t;
757 int tag; 757 lu_byte tag;
758 lua_lock(L); 758 lua_lock(L);
759 api_checkpop(L, 1); 759 api_checkpop(L, 1);
760 t = gettable(L, idx); 760 t = gettable(L, idx);
@@ -766,7 +766,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) {
766 766
767LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) { 767LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
768 Table *t; 768 Table *t;
769 int tag; 769 lu_byte tag;
770 lua_lock(L); 770 lua_lock(L);
771 t = gettable(L, idx); 771 t = gettable(L, idx);
772 luaH_fastgeti(t, n, s2v(L->top.p), tag); 772 luaH_fastgeti(t, n, s2v(L->top.p), tag);
@@ -1231,7 +1231,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1231 api_check(L, 0 <= param && param < LUA_GCPN, "invalid parameter"); 1231 api_check(L, 0 <= param && param < LUA_GCPN, "invalid parameter");
1232 res = cast_int(luaO_applyparam(g->gcparams[param], 100)); 1232 res = cast_int(luaO_applyparam(g->gcparams[param], 100));
1233 if (value >= 0) 1233 if (value >= 0)
1234 g->gcparams[param] = luaO_codeparam(value); 1234 g->gcparams[param] = luaO_codeparam(cast_uint(value));
1235 break; 1235 break;
1236 } 1236 }
1237 default: res = -1; /* invalid option */ 1237 default: res = -1; /* invalid option */
@@ -1353,7 +1353,7 @@ LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
1353 Udata *u; 1353 Udata *u;
1354 lua_lock(L); 1354 lua_lock(L);
1355 api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value"); 1355 api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value");
1356 u = luaS_newudata(L, size, nuvalue); 1356 u = luaS_newudata(L, size, cast(unsigned short, nuvalue));
1357 setuvalue(L, s2v(L->top.p), u); 1357 setuvalue(L, s2v(L->top.p), u);
1358 api_incr_top(L); 1358 api_incr_top(L);
1359 advancegc(L, size); 1359 advancegc(L, size);