Skip to content

Commit

Permalink
Cleanup warnings for luac_cross.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johny Mattsson committed Aug 4, 2021
1 parent aea83da commit 7b028d5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions components/lua/lmathlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,6 @@ LROT_END(math, NULL, 0)
** Open math library
*/
LUALIB_API int luaopen_math (lua_State *L) {
(void)L;
return 0;
}
1 change: 1 addition & 0 deletions components/lua/loadlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
11 changes: 5 additions & 6 deletions components/lua/lrotable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions components/lua/lstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/lua/lundump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions components/luac_cross/lflashimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions components/luac_cross/loslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 7b028d5

Please sign in to comment.