From 9fa63a62682c1353eeabd4575152941fa6f3e70f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 22 Mar 2024 14:06:11 -0300 Subject: Some 'unsigned int' changed to 'unsigned' 'unsigned int' is too long sometimes. (We already write 'long' instead of 'long int'...) --- lcode.h | 2 +- llimits.h | 2 +- lstate.c | 2 +- lstring.c | 6 +++--- lstring.h | 4 ++-- ltable.c | 20 ++++++++++---------- ltable.h | 8 ++++---- ltablib.c | 3 +-- ltests.c | 2 +- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lcode.h b/lcode.h index 0b971fc4..5b8eb29e 100644 --- a/lcode.h +++ b/lcode.h @@ -60,7 +60,7 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); -LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned Bx); LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, int B, int C, int k); LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); diff --git a/llimits.h b/llimits.h index 3bcd1b7f..2adbd32e 100644 --- a/llimits.h +++ b/llimits.h @@ -91,7 +91,7 @@ typedef signed char ls_byte; #define L_P2I size_t #endif -#define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX)) +#define point2uint(p) cast_uint((L_P2I)(p) & UINT_MAX) diff --git a/lstate.c b/lstate.c index 2ae76d8c..c3422589 100644 --- a/lstate.c +++ b/lstate.c @@ -320,7 +320,7 @@ LUA_API int lua_closethread (lua_State *L, lua_State *from) { } -LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned int seed) { +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) { int i; lua_State *L; global_State *g; diff --git a/lstring.c b/lstring.c index 9570e798..a374c965 100644 --- a/lstring.c +++ b/lstring.c @@ -40,7 +40,7 @@ int luaS_eqlngstr (TString *a, TString *b) { } -unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { +unsigned luaS_hash (const char *str, size_t l, unsigned seed) { unsigned int h = seed ^ cast_uint(l); for (; l > 0; l--) h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); @@ -48,7 +48,7 @@ unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { } -unsigned int luaS_hashlongstr (TString *ts) { +unsigned luaS_hashlongstr (TString *ts) { lua_assert(ts->tt == LUA_VLNGSTR); if (ts->extra == 0) { /* no hash? */ size_t len = ts->u.lnglen; @@ -155,7 +155,7 @@ size_t luaS_sizelngstr (size_t len, int kind) { ** creates a new string object */ static TString *createstrobj (lua_State *L, size_t totalsize, int tag, - unsigned int h) { + unsigned h) { TString *ts; GCObject *o; o = luaC_newobj(L, tag, totalsize); diff --git a/lstring.h b/lstring.h index e321bd43..b7226d83 100644 --- a/lstring.h +++ b/lstring.h @@ -43,8 +43,8 @@ #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) -LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); -LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); +LUAI_FUNC unsigned luaS_hash (const char *str, size_t l, unsigned seed); +LUAI_FUNC unsigned luaS_hashlongstr (TString *ts); LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); LUAI_FUNC void luaS_resize (lua_State *L, int newsize); LUAI_FUNC void luaS_clearcache (global_State *g); diff --git a/ltable.c b/ltable.c index f62f36bc..ef19a5c5 100644 --- a/ltable.c +++ b/ltable.c @@ -358,8 +358,8 @@ static unsigned int arrayindex (lua_Integer k) { ** elements in the array part, then elements in the hash part. The ** beginning of a traversal is signaled by 0. */ -static unsigned int findindex (lua_State *L, Table *t, TValue *key, - unsigned int asize) { +static unsigned findindex (lua_State *L, Table *t, TValue *key, + unsigned asize) { unsigned int i; if (ttisnil(key)) return 0; /* first iteration */ i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; @@ -462,7 +462,7 @@ static int keyinarray (Table *t, lua_Integer key) { ** will go to the array part; return the optimal size. (The condition ** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.) */ -static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { +static unsigned computesizes (unsigned nums[], unsigned *pna) { int i; unsigned int twotoi; /* 2^i (candidate for optimal size) */ unsigned int a = 0; /* number of elements smaller than 2^i */ @@ -506,7 +506,7 @@ l_sinline int arraykeyisempty (const Table *t, lua_Integer key) { ** number of keys that will go into corresponding slice and return ** total number of non-nil keys. */ -static unsigned int numusearray (const Table *t, unsigned int *nums) { +static unsigned numusearray (const Table *t, unsigned *nums) { int lg; unsigned int ttlg; /* 2^lg */ unsigned int ause = 0; /* summation of 'nums' */ @@ -533,7 +533,7 @@ static unsigned int numusearray (const Table *t, unsigned int *nums) { } -static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) { +static int numusehash (const Table *t, unsigned *nums, unsigned *pna) { int totaluse = 0; /* total number of elements */ int ause = 0; /* elements added to 'nums' (can go to array part) */ int i = sizenode(t); @@ -567,8 +567,8 @@ static size_t concretesize (unsigned int size) { static ArrayCell *resizearray (lua_State *L , Table *t, - unsigned int oldasize, - unsigned int newasize) { + unsigned oldasize, + unsigned newasize) { size_t oldasizeb = concretesize(oldasize); size_t newasizeb = concretesize(newasize); void *a = luaM_reallocvector(L, t->array, oldasizeb, newasizeb, lu_byte); @@ -583,7 +583,7 @@ static ArrayCell *resizearray (lua_State *L , Table *t, ** comparison ensures that the shift in the second one does not ** overflow. */ -static void setnodevector (lua_State *L, Table *t, unsigned int size) { +static void setnodevector (lua_State *L, Table *t, unsigned size) { if (size == 0) { /* no elements to hash part? */ t->node = cast(Node *, dummynode); /* use common 'dummynode' */ t->lsizenode = 0; @@ -695,8 +695,8 @@ static void clearNewSlice (Table *t, unsigned oldasize, unsigned newasize) { ** nils and reinserts the elements of the old hash back into the new ** parts of the table. */ -void luaH_resize (lua_State *L, Table *t, unsigned int newasize, - unsigned int nhsize) { +void luaH_resize (lua_State *L, Table *t, unsigned newasize, + unsigned nhsize) { Table newt; /* to keep the new hash part */ unsigned int oldasize = setlimittosize(t); ArrayCell *newarray; diff --git a/ltable.h b/ltable.h index 1f2ea3ee..4734bd50 100644 --- a/ltable.h +++ b/ltable.h @@ -151,13 +151,13 @@ LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, TValue *value, int hres); LUAI_FUNC Table *luaH_new (lua_State *L); -LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, - unsigned int nhsize); -LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); +LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned nasize, + unsigned nhsize); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned nasize); LUAI_FUNC void luaH_free (lua_State *L, Table *t); LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); LUAI_FUNC lua_Unsigned luaH_getn (Table *t); -LUAI_FUNC unsigned int luaH_realasize (const Table *t); +LUAI_FUNC unsigned luaH_realasize (const Table *t); #if defined(LUA_DEBUG) diff --git a/ltablib.c b/ltablib.c index 4c3f6900..a402daea 100644 --- a/ltablib.c +++ b/ltablib.c @@ -329,8 +329,7 @@ static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) { /* ** Quicksort algorithm (recursive function) */ -static void auxsort (lua_State *L, IdxT lo, IdxT up, - unsigned int rnd) { +static void auxsort (lua_State *L, IdxT lo, IdxT up, unsigned rnd) { while (lo < up) { /* loop for tail recursion */ IdxT p; /* Pivot index */ IdxT n; /* to be used later */ diff --git a/ltests.c b/ltests.c index 1a34870e..4780673e 100644 --- a/ltests.c +++ b/ltests.c @@ -1008,7 +1008,7 @@ static int table_query (lua_State *L) { lua_pushinteger(L, t->alimit); return 3; } - else if ((unsigned int)i < asize) { + else if (cast_uint(i) < asize) { lua_pushinteger(L, i); arr2obj(t, i + 1, s2v(L->top.p)); api_incr_top(L); -- cgit v1.2.3-55-g6feb