Cleanup warnings for luac_cross.

This commit is contained in:
Johny Mattsson 2021-08-04 12:42:43 +10:00
parent aea83da7df
commit 7b028d5c5d
7 changed files with 15 additions and 9 deletions

View File

@ -361,5 +361,6 @@ LROT_END(math, NULL, 0)
** Open math library
*/
LUALIB_API int luaopen_math (lua_State *L) {
(void)L;
return 0;
}

View File

@ -625,6 +625,7 @@ static int ll_seeall (lua_State *L) {
static void setpath (lua_State *L, const char *fieldname, const char *envname,
const char *def) {
(void)envname;
const char *path = NULL; /* getenv(envname) not used in NodeMCU */;
if (path == NULL) /* no environment variable? */
lua_pushstring(L, def); /* use default */

View File

@ -10,9 +10,9 @@
#include "lapi.h"
#ifdef _MSC_VER
#define ALIGNED_STRING (__declspec( align( 4 ) ) char*)
#define ALIGNED_STRING __declspec( align( 4 ) ) char
#else
#define ALIGNED_STRING (__attribute__((aligned(4))) char *)
#define ALIGNED_STRING __attribute__((aligned(4))) char
#endif
#define LA_LINES 32
#define LA_SLOTS 4
@ -82,7 +82,8 @@ static void update_cache(unsigned hash, ROTable *rotable, unsigned ndx) {
*/
const TValue* luaR_findentry(ROTable *rotable, TString *key, unsigned *ppos) {
const luaR_entry *pentry = rotable;
const char *strkey = key ? getstr(key) : ALIGNED_STRING "__metatable" ;
static const ALIGNED_STRING metatablestr[] = "__metatable";
const char *strkey = key ? getstr(key) : metatablestr;
unsigned hash = HASH(rotable, key);
unsigned i = 0;
@ -148,9 +149,7 @@ void luaR_next(lua_State *L, ROTable *rotable, TValue *key, TValue *val) {
luaR_next_helper(L, rotable, 0, key, val);
else if (ttisstring(key)) {
/* Find the previous key again */
if (ttisstring(key)) {
luaR_findentry(rotable, rawtsvalue(key), &keypos);
}
luaR_findentry(rotable, rawtsvalue(key), &keypos);
/* Advance to next key */
keypos ++;
luaR_next_helper(L, rotable, keypos, key, val);

View File

@ -82,6 +82,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
static int lua_is_ptr_in_ro_area(const char *p) {
#ifdef LUA_CROSS_COMPILER
(void)p;
return 0; // TStrings are never in RO in luac.cross
#else
return IN_RODATA_AREA(p);

View File

@ -146,7 +146,7 @@ static lua_Number LoadNumber(LoadState* S)
LoadVar(S,y);
x = (lua_Number)y;
} break;
default: lua_assert(0);
default: lua_assert(0); __builtin_unreachable();
}
}
else

View File

@ -125,6 +125,7 @@ extern void __attribute__((noreturn)) fatal(const char* message);
* Serial allocator. Throw a luac-style out of memory error is allocaiton fails.
*/
static void *flashAlloc(lua_State* L, size_t n) {
(void)L;
void *p = (void *)(flashImage + curOffset);
curOffset += ALIGN(n)>>WORDSHIFT;
if (curOffset > LUA_MAX_FLASH_SIZE) {
@ -140,6 +141,7 @@ static void *flashAlloc(lua_State* L, size_t n) {
*/
#define toFlashAddr(l, pd, s) _toFlashAddr(l, &(pd), s)
static void _toFlashAddr(lua_State* L, FlashAddr *a, void *p) {
(void)L;
uint doffset = cast(char *, a) - cast(char *,flashImage);
lua_assert(!(doffset & (WORDSIZE-1))); // check word aligned
doffset >>= WORDSHIFT; // and convert to a word offset
@ -399,9 +401,10 @@ static void *functionToFlash(lua_State* L, const Proto* orig) {
uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w,
void* data, int strip,
lu_int32 address, lu_int32 maxSize) {
(void)strip;
// parameter strip is ignored for now
FlashHeader *fh = cast(FlashHeader *, flashAlloc(L, sizeof(FlashHeader)));
int i, status;
int status;
lua_newtable(L);
scanProtoStrings(L, main);
createROstrt(L, fh);
@ -413,7 +416,7 @@ uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w,
fatal ("The image is too large for specfied LFS size");
}
if (address) { /* in absolute mode convert addresses to mapped address */
for (i = 0 ; i < curOffset; i++)
for (uint i = 0 ; i < curOffset; i++)
if (getFlashAddrTag(i))
flashImage[i] = 4*flashImage[i] + address;
lua_unlock(L);

View File

@ -246,6 +246,7 @@ LROT_END(oslib, NULL, 0)
LUALIB_API int luaopen_os (lua_State *L) {
(void)L;
//LREGISTER(L, LUA_OSLIBNAME, oslib); // <------------- ???
return 0;
}