Jelajahi Sumber

fix: 修正部分编译警告,包括但不限于 未使用的变量,未做类型转换,未使用的方法

Wendal Chen 4 tahun lalu
induk
melakukan
81e34ec4c0

+ 115 - 115
lua/src/loadlib.c

@@ -65,7 +65,7 @@
 ** unique key for table in the registry that keeps handles
 ** for all loaded C libraries
 */
-static const int CLIBS = 0;
+// static const int CLIBS = 0;
 
 #define LIB_FAIL	"open"
 
@@ -80,7 +80,7 @@ static const int CLIBS = 0;
 /*
 ** unload library 'lib'
 */
-static void lsys_unloadlib (void *lib);
+// static void lsys_unloadlib (void *lib);
 
 /*
 ** load C library in file 'path'. If 'seeglb', load with all names in
@@ -100,160 +100,160 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym);
 
 
 
-#if defined(LUA_USE_DLOPEN)	/* { */
-/*
-** {========================================================================
-** This is an implementation of loadlib based on the dlfcn interface.
-** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
-** NetBSD, AIX 4.2, HPUX 11, and  probably most other Unix flavors, at least
-** as an emulation layer on top of native functions.
-** =========================================================================
-*/
+// #if defined(LUA_USE_DLOPEN)	/* { */
+// /*
+// ** {========================================================================
+// ** This is an implementation of loadlib based on the dlfcn interface.
+// ** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
+// ** NetBSD, AIX 4.2, HPUX 11, and  probably most other Unix flavors, at least
+// ** as an emulation layer on top of native functions.
+// ** =========================================================================
+// */
 
-#include <dlfcn.h>
+// #include <dlfcn.h>
 
-/*
-** Macro to convert pointer-to-void* to pointer-to-function. This cast
-** is undefined according to ISO C, but POSIX assumes that it works.
-** (The '__extension__' in gnu compilers is only to avoid warnings.)
-*/
-#if defined(__GNUC__)
-#define cast_func(p) (__extension__ (lua_CFunction)(p))
-#else
-#define cast_func(p) ((lua_CFunction)(p))
-#endif
+// /*
+// ** Macro to convert pointer-to-void* to pointer-to-function. This cast
+// ** is undefined according to ISO C, but POSIX assumes that it works.
+// ** (The '__extension__' in gnu compilers is only to avoid warnings.)
+// */
+// #if defined(__GNUC__)
+// #define cast_func(p) (__extension__ (lua_CFunction)(p))
+// #else
+// #define cast_func(p) ((lua_CFunction)(p))
+// #endif
 
 
-static void lsys_unloadlib (void *lib) {
-  dlclose(lib);
-}
+// static void lsys_unloadlib (void *lib) {
+//   dlclose(lib);
+// }
 
 
-static void *lsys_load (lua_State *L, const char *path, int seeglb) {
-  void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
-  if (lib == NULL) lua_pushstring(L, dlerror());
-  return lib;
-}
+// static void *lsys_load (lua_State *L, const char *path, int seeglb) {
+//   void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
+//   if (lib == NULL) lua_pushstring(L, dlerror());
+//   return lib;
+// }
 
 
-static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
-  lua_CFunction f = cast_func(dlsym(lib, sym));
-  if (f == NULL) lua_pushstring(L, dlerror());
-  return f;
-}
+// static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
+//   lua_CFunction f = cast_func(dlsym(lib, sym));
+//   if (f == NULL) lua_pushstring(L, dlerror());
+//   return f;
+// }
 
-/* }====================================================== */
+// /* }====================================================== */
 
 
 
-#elif defined(LUA_DL_DLL)	/* }{ */
-/*
-** {======================================================================
-** This is an implementation of loadlib for Windows using native functions.
-** =======================================================================
-*/
+// #elif defined(LUA_DL_DLL)	/* }{ */
+// /*
+// ** {======================================================================
+// ** This is an implementation of loadlib for Windows using native functions.
+// ** =======================================================================
+// */
 
-#include <windows.h>
+// #include <windows.h>
 
 
-/*
-** optional flags for LoadLibraryEx
-*/
-#if !defined(LUA_LLE_FLAGS)
-#define LUA_LLE_FLAGS	0
-#endif
+// /*
+// ** optional flags for LoadLibraryEx
+// */
+// #if !defined(LUA_LLE_FLAGS)
+// #define LUA_LLE_FLAGS	0
+// #endif
 
 
-#undef setprogdir
+// #undef setprogdir
 
 
-/*
-** Replace in the path (on the top of the stack) any occurrence
-** of LUA_EXEC_DIR with the executable's path.
-*/
-static void setprogdir (lua_State *L) {
-  char buff[MAX_PATH + 1];
-  char *lb;
-  DWORD nsize = sizeof(buff)/sizeof(char);
-  DWORD n = GetModuleFileNameA(NULL, buff, nsize);  /* get exec. name */
-  if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
-    luaL_error(L, "unable to get ModuleFileName");
-  else {
-    *lb = '\0';  /* cut name on the last '\\' to get the path */
-    luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
-    lua_remove(L, -2);  /* remove original string */
-  }
-}
+// /*
+// ** Replace in the path (on the top of the stack) any occurrence
+// ** of LUA_EXEC_DIR with the executable's path.
+// */
+// static void setprogdir (lua_State *L) {
+//   char buff[MAX_PATH + 1];
+//   char *lb;
+//   DWORD nsize = sizeof(buff)/sizeof(char);
+//   DWORD n = GetModuleFileNameA(NULL, buff, nsize);  /* get exec. name */
+//   if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
+//     luaL_error(L, "unable to get ModuleFileName");
+//   else {
+//     *lb = '\0';  /* cut name on the last '\\' to get the path */
+//     luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
+//     lua_remove(L, -2);  /* remove original string */
+//   }
+// }
 
 
 
 
-static void pusherror (lua_State *L) {
-  int error = GetLastError();
-  char buffer[128];
-  if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
-      NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL))
-    lua_pushstring(L, buffer);
-  else
-    lua_pushfstring(L, "system error %d\n", error);
-}
+// static void pusherror (lua_State *L) {
+//   int error = GetLastError();
+//   char buffer[128];
+//   if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+//       NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL))
+//     lua_pushstring(L, buffer);
+//   else
+//     lua_pushfstring(L, "system error %d\n", error);
+// }
 
-static void lsys_unloadlib (void *lib) {
-  FreeLibrary((HMODULE)lib);
-}
+// static void lsys_unloadlib (void *lib) {
+//   FreeLibrary((HMODULE)lib);
+// }
 
 
-static void *lsys_load (lua_State *L, const char *path, int seeglb) {
-  HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
-  (void)(seeglb);  /* not used: symbols are 'global' by default */
-  if (lib == NULL) pusherror(L);
-  return lib;
-}
+// static void *lsys_load (lua_State *L, const char *path, int seeglb) {
+//   HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
+//   (void)(seeglb);  /* not used: symbols are 'global' by default */
+//   if (lib == NULL) pusherror(L);
+//   return lib;
+// }
 
 
-static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
-  lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
-  if (f == NULL) pusherror(L);
-  return f;
-}
+// static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
+//   lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
+//   if (f == NULL) pusherror(L);
+//   return f;
+// }
 
-/* }====================================================== */
+// /* }====================================================== */
 
 
-#else				/* }{ */
-/*
-** {======================================================
-** Fallback for other systems
-** =======================================================
-*/
+// #else				/* }{ */
+// /*
+// ** {======================================================
+// ** Fallback for other systems
+// ** =======================================================
+// */
 
-#undef LIB_FAIL
-#define LIB_FAIL	"absent"
+// #undef LIB_FAIL
+// #define LIB_FAIL	"absent"
 
 
-#define DLMSG	"dynamic libraries not enabled; check your Lua installation"
+// #define DLMSG	"dynamic libraries not enabled; check your Lua installation"
 
 
-static void lsys_unloadlib (void *lib) {
-  (void)(lib);  /* not used */
-}
+// static void lsys_unloadlib (void *lib) {
+//   (void)(lib);  /* not used */
+// }
 
 
-static void *lsys_load (lua_State *L, const char *path, int seeglb) {
-  (void)(path); (void)(seeglb);  /* not used */
-  lua_pushliteral(L, DLMSG);
-  return NULL;
-}
+// static void *lsys_load (lua_State *L, const char *path, int seeglb) {
+//   (void)(path); (void)(seeglb);  /* not used */
+//   lua_pushliteral(L, DLMSG);
+//   return NULL;
+// }
 
 
-static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
-  (void)(lib); (void)(sym);  /* not used */
-  lua_pushliteral(L, DLMSG);
-  return NULL;
-}
+// static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
+//   (void)(lib); (void)(sym);  /* not used */
+//   lua_pushliteral(L, DLMSG);
+//   return NULL;
+// }
 
-/* }====================================================== */
-#endif				/* } */
+// /* }====================================================== */
+// #endif				/* } */
 
 
 /*

+ 12 - 12
lua/src/lstrlib.c

@@ -190,17 +190,17 @@ static int writer (lua_State *L, const void *b, size_t size, void *B) {
 }
 
 
-static int str_dump (lua_State *L) {
-  luaL_Buffer b;
-  int strip = lua_toboolean(L, 2);
-  luaL_checktype(L, 1, LUA_TFUNCTION);
-  lua_settop(L, 1);
-  luaL_buffinit(L,&b);
-  if (lua_dump(L, writer, &b, strip) != 0)
-    return luaL_error(L, "unable to dump given function");
-  luaL_pushresult(&b);
-  return 1;
-}
+// static int str_dump (lua_State *L) {
+//   luaL_Buffer b;
+//   int strip = lua_toboolean(L, 2);
+//   luaL_checktype(L, 1, LUA_TFUNCTION);
+//   lua_settop(L, 1);
+//   luaL_buffinit(L,&b);
+//   if (lua_dump(L, writer, &b, strip) != 0)
+//     return luaL_error(L, "unable to dump given function");
+//   luaL_pushresult(&b);
+//   return 1;
+// }
 
 
 
@@ -1556,7 +1556,7 @@ void luat_str_fromhex(char* str, size_t len, char* buff) {
   {
     char a = *(str + i*2);
     char b = *(str + i*2 + 1);
-    printf("%d %c %c\r\n", i, a, b);
+    //printf("%d %c %c\r\n", i, a, b);
     a = (a <= '9') ? a - '0' : (a & 0x7) + 9;
     b = (b <= '9') ? b - '0' : (b & 0x7) + 9;
     if (a >=0 && b >= 0)

+ 5 - 5
luat/modules/luat_lib_crypto.c

@@ -271,8 +271,8 @@ local crc = crypto.crc16("")
 static int l_crypto_crc16(lua_State *L)
 {   
     size_t inputLen;
-    const char  *inputmethod = luaL_checkstring(L, 1);
-    const char *inputData = lua_tolstring(L,2,&inputLen);
+    const unsigned char  *inputmethod = (const unsigned char*)luaL_checkstring(L, 1);
+    const unsigned char *inputData = (const unsigned char*)lua_tolstring(L,2,&inputLen);
     uint16_t poly = luaL_optnumber(L,3,0x0000);
     uint16_t initial = luaL_optnumber(L,4,0x0000);
     uint16_t finally = luaL_optnumber(L,5,0x0000);
@@ -295,7 +295,7 @@ local crc = crypto.crc16_modbus(data)
 static int l_crypto_crc16_modbus(lua_State *L)
 {
     size_t len = 0;
-    const char *inputData = luaL_checklstring(L, 1, &len);
+    const unsigned char *inputData = (const unsigned char*)luaL_checklstring(L, 1, &len);
 
     lua_pushinteger(L, calcCRC16_modbus(inputData, len));
     return 1;
@@ -313,7 +313,7 @@ local crc = crypto.crc32(data)
 static int l_crypto_crc32(lua_State *L)
 {
     size_t len = 0;
-    const char *inputData = luaL_checklstring(L, 1, &len);
+    const unsigned char *inputData = (const unsigned char*)luaL_checklstring(L, 1, &len);
 
     lua_pushinteger(L, calcCRC32(inputData, len));
     return 1;
@@ -331,7 +331,7 @@ local crc = crypto.crc8(data)
 static int l_crypto_crc8(lua_State *L)
 {
     size_t len = 0;
-    const char *inputData = luaL_checklstring(L, 1, &len);
+    const unsigned char *inputData = (const unsigned char*)luaL_checklstring(L, 1, &len);
 
     lua_pushinteger(L, calcCRC8(inputData, len));
     return 1;

+ 3 - 3
luat/modules/luat_lib_ctiot.c

@@ -43,7 +43,7 @@ static int luat_ctiot_msg_handler(lua_State *L, void* ptr)
 		case CTIOT_TX_ACK:
 		case CTIOT_TX_DONE:
 			goto LUAT_CTIOT_MSG_HANDLER_DONE;
-			break;
+			//break;
 		default:
 			error = 1;
 			error_code = code;
@@ -74,7 +74,7 @@ static int luat_ctiot_msg_handler(lua_State *L, void* ptr)
 		{
 		case CTIOT_AIR_NON_SEND_START:
 			goto LUAT_CTIOT_MSG_HANDLER_DONE;
-			break;
+			//break;
 		default:
 			error = 0;
 			error_code = 0;
@@ -203,7 +203,7 @@ void luat_ctiot_callback(uint8_t type, uint8_t code, void *buf, uint32_t len)
 			memcpy(buff + 6, buf, len);
 		}
 	}
-	luat_msgbus_put(&msg, -1);
+	luat_msgbus_put(&msg, 0);
 
 }
 /**

+ 1 - 1
luat/modules/luat_lib_dbg.c

@@ -15,7 +15,7 @@
  * 5 , wait for step in
  */
 static int cur_hook_state = 0;
-static int cur_run_state = 0;
+// static int cur_run_state = 0;
 static lua_State *dbg_L = NULL;
 static lua_Debug *dbg_ar = NULL;
 static line_bp_t breakpoints[BP_LINE_COUNT] = {0};

+ 1 - 1
luat/modules/luat_lib_gpio.c

@@ -233,7 +233,7 @@ static const rotable_Reg reg_gpio[] =
 };
 
 LUAMOD_API int luaopen_gpio( lua_State *L ) {
-    int i;
+    // int i;
     for (size_t i = 0; i < GPIO_IRQ_COUNT; i++) {
         irq_cbs[i].pin = -1;
     }

+ 3 - 3
luat/modules/luat_lib_i2c.c

@@ -98,7 +98,7 @@ static void i2c_soft_send_byte(luat_ei2c *ei2c,unsigned char data)
         luat_timer_us_delay(5);
     }
 }
-static unsigned char i2c_soft_recv_byte(luat_ei2c *ei2c)
+static char i2c_soft_recv_byte(luat_ei2c *ei2c)
 {
     unsigned char i = 8;
     unsigned char data = 0;
@@ -117,7 +117,7 @@ static unsigned char i2c_soft_recv_byte(luat_ei2c *ei2c)
     luat_gpio_set(ei2c->scl, Luat_GPIO_LOW);
     return(data);
 }
-static unsigned char i2c_soft_recv(luat_ei2c *ei2c,unsigned char addr, char *buff, size_t len)
+static char i2c_soft_recv(luat_ei2c *ei2c,unsigned char addr, char *buff, size_t len)
 {
     size_t i;
     i2c_soft_start(ei2c);
@@ -138,7 +138,7 @@ static unsigned char i2c_soft_recv(luat_ei2c *ei2c,unsigned char addr, char *buf
     i2c_soft_stop(ei2c);
     return 0;
 }
-static unsigned char i2c_soft_send(luat_ei2c *ei2c,unsigned char addr,char *data, size_t len)
+static char i2c_soft_send(luat_ei2c *ei2c,unsigned char addr,char *data, size_t len)
 {
     size_t i;
     i2c_soft_start(ei2c);

+ 11 - 11
luat/modules/luat_lib_mqttcore.c

@@ -18,14 +18,14 @@ enum msgTypes
 	PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,
 	PINGREQ, PINGRESP, DISCONNECT, AUTH
 };
-static const char *packet_names[] =
-{
-	"RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
-	"PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
-	"PINGREQ", "PINGRESP", "DISCONNECT", "AUTH"
-};
+// static const char *packet_names[] =
+// {
+// 	"RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
+// 	"PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
+// 	"PINGREQ", "PINGRESP", "DISCONNECT", "AUTH"
+// };
 
-static const char** MQTTClient_packet_names = packet_names;
+// static const char** MQTTClient_packet_names = packet_names;
 
 
 /**
@@ -33,10 +33,10 @@ static const char** MQTTClient_packet_names = packet_names;
  * @param ptype packet code
  * @return the corresponding string, or "UNKNOWN"
  */
-static const char* MQTTPacket_name(int ptype)
-{
-	return (ptype >= 0 && ptype <= AUTH) ? packet_names[ptype] : "UNKNOWN";
-}
+// static const char* MQTTPacket_name(int ptype)
+// {
+// 	return (ptype >= 0 && ptype <= AUTH) ? packet_names[ptype] : "UNKNOWN";
+// }
 
 /**
  * Encodes the message length according to the MQTT algorithm

+ 3 - 3
luat/modules/luat_lib_sensor.c

@@ -429,14 +429,14 @@ sensor.ws2812b(7,buff,300,700,700,700)
   while(t1l_temp--)
 static int l_sensor_ws2812b(lua_State *L)
 {
-  unsigned char j;
+  int j;
   size_t len,i;
-  const char *send_buff;
+  const char *send_buff = NULL;
   int pin = luaL_checkinteger(L, 1);
   if (lua_isuserdata(L, 2))
   {
     luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
-    send_buff = buff->addr;
+    send_buff = (const char*)buff->addr;
     len = buff->len;
   }
   else

+ 15 - 15
luat/modules/luat_lib_spi.c

@@ -85,11 +85,11 @@ local recv = spi.transfer(0, buff)--把zbuff数据从指针开始,全发出去
 */
 static int l_spi_transfer(lua_State *L) {
     int id = luaL_checkinteger(L, 1);
-    size_t len;
-    const char* send_buff;
+    size_t len = 0;
+    const char* send_buff = NULL;
     if(lua_isuserdata(L, 2)){//zbuff对象特殊处理
         luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
-        send_buff = buff->addr+buff->cursor;
+        send_buff = (const char*)(buff->addr+buff->cursor);
         len = buff->len - buff->cursor;
     }else{
         send_buff = lua_tolstring(L, 2, &len);
@@ -161,11 +161,11 @@ local result = spi.send(0, buff)--把zbuff数据从指针开始,全发出去
 */
 static int l_spi_send(lua_State *L) {
     int id = luaL_checkinteger(L, 1);
-    size_t len;
-    const char* send_buff;
+    size_t len = 0;
+    const char* send_buff = NULL;
     if(lua_isuserdata(L, 2)){//zbuff对象特殊处理
-        luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
-        send_buff = buff->addr+buff->cursor;
+        luat_zbuff_t *buff = (luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE);
+        send_buff = (const char*)(buff->addr+buff->cursor);
         len = buff->len - buff->cursor;
     }else{
         send_buff = lua_tolstring(L, 2, &len);
@@ -255,11 +255,11 @@ local recv = spi_device:transfer(buff)--把zbuff数据从指针开始,全发
 */
 static int l_spi_device_transfer(lua_State *L) {
     luat_spi_device_t* spi_device = (luat_spi_device_t*)lua_touserdata(L, 1);
-    size_t len;
-    const char* send_buff;
+    size_t len = 0;
+    const char* send_buff = NULL;
     if(lua_isuserdata(L, 2)){//zbuff对象特殊处理
-        luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
-        send_buff = buff->addr+buff->cursor;
+        luat_zbuff_t *buff = (luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE);
+        send_buff = (const char*)(buff->addr+buff->cursor);
         len = buff->len - buff->cursor;
     }else{
         send_buff = lua_tolstring(L, 2, &len);
@@ -304,11 +304,11 @@ local result = spi_device:send(buff)--把zbuff数据从指针开始,全发出
 */
 static int l_spi_device_send(lua_State *L) {
     luat_spi_device_t* spi_device = (luat_spi_device_t*)lua_touserdata(L, 1);
-    size_t len;
-    const char* send_buff;
+    size_t len = 0;
+    const char* send_buff = NULL;
     if(lua_isuserdata(L, 2)){//zbuff对象特殊处理
-        luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
-        send_buff = buff->addr+buff->cursor;
+        luat_zbuff_t *buff = (luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE);
+        send_buff = (const char*)(buff->addr+buff->cursor);
         len = buff->len - buff->cursor;
     }else{
         send_buff = lua_tolstring(L, 2, &len);

+ 14 - 14
luat/modules/luat_lib_zbuff.c

@@ -72,7 +72,7 @@ int add_bytes(luat_zbuff_t *buff, const char *source, size_t len)
 #define GET_POINT_CASE(n, point)           \
     case n:                                \
         return GET_POINT_##n(buff, point); \
-        break
+
 //获取某点的颜色
 uint32_t get_framebuffer_point(luat_zbuff_t *buff,uint32_t point)
 {
@@ -521,7 +521,7 @@ static int l_zbuff_unpack(lua_State *L)
     luat_zbuff_t *buff = tozbuff(L);
     char *f = (char *)luaL_checkstring(L, 2);
     size_t len = buff->len - buff->cursor;
-    const char *s = buff->addr + buff->cursor;
+    const char *s = (const char*)(buff->addr + buff->cursor);
     int i = 0;
     int n = 0;
     int swap = 0;
@@ -672,7 +672,7 @@ static int l_zbuff_toStr(lua_State *L)
     int len = luaL_optinteger(L, 3, buff->len);
     if (start + len > buff->len)
         len = buff->len - start;
-    lua_pushlstring(L, buff->addr + start, len);
+    lua_pushlstring(L, (const char*)(buff->addr + start), len);
     return 1;
 }
 
@@ -817,14 +817,14 @@ static int l_zbuff_draw_rectangle(lua_State *L)
 {
     luat_zbuff_t *buff = tozbuff(L);
     if(buff->width<=0) return 0;//不是framebuffer数据
-    uint32_t x1 = luaL_checkinteger(L,2);  CHECK0(x1,buff->width);
-    uint32_t y1 = luaL_checkinteger(L,3);  CHECK0(y1,buff->height);
-    uint32_t x2 = luaL_checkinteger(L,4);  CHECK0(x2,buff->width);
-    uint32_t y2 = luaL_checkinteger(L,5);  CHECK0(y2,buff->height);
-    uint32_t color = luaL_optinteger(L,6,0);
+    int32_t x1 = (int32_t)luaL_checkinteger(L,2);  CHECK0(x1,buff->width);
+    int32_t y1 = (int32_t)luaL_checkinteger(L,3);  CHECK0(y1,buff->height);
+    int32_t x2 = (int32_t)luaL_checkinteger(L,4);  CHECK0(x2,buff->width);
+    int32_t y2 = (int32_t)luaL_checkinteger(L,5);  CHECK0(y2,buff->height);
+    int32_t color = (int32_t)luaL_optinteger(L,6,0);
     uint8_t fill = lua_toboolean(L,7);
     int x,y;
-    uint32_t xmax=x1>x2?x1:x2,xmin=x1>x2?x2:x1,ymax=y1>y2?y1:y2,ymin=y1>y2?y2:y1;
+    int32_t xmax=x1>x2?x1:x2,xmin=x1>x2?x2:x1,ymax=y1>y2?y1:y2,ymin=y1>y2?y2:y1;
     if(fill){
         for(x=xmin;x<=xmax;x++)
             for(y=ymin;y<=ymax;y++)
@@ -879,10 +879,10 @@ static int l_zbuff_draw_circle(lua_State *L)
 {
     luat_zbuff_t *buff = tozbuff(L);
     if(buff->width<=0) return 0;//不是framebuffer数据
-    uint32_t xc = luaL_checkinteger(L,2);
-    uint32_t yc = luaL_checkinteger(L,3);
-    uint32_t r = luaL_checkinteger(L,4);
-    uint32_t color = luaL_optinteger(L,5,0);
+    int32_t xc = luaL_checkinteger(L,2);
+    int32_t yc = luaL_checkinteger(L,3);
+    int32_t r = luaL_checkinteger(L,4);
+    int32_t color = luaL_optinteger(L,5,0);
     uint8_t fill = lua_toboolean(L,6);
 
     //代码参考https://www.cnblogs.com/wlzy/p/8695226.html
@@ -931,7 +931,7 @@ local data = buff[0]
 static int l_zbuff_index(lua_State *L)
 {
     luat_zbuff_t **pp = luaL_checkudata(L, 1, LUAT_ZBUFF_TYPE);
-    int i;
+    // int i;
 
     luaL_getmetatable(L, LUAT_ZBUFF_TYPE);
     lua_pushvalue(L, 2);

+ 1 - 2
luat/modules/luat_luat_bin.c

@@ -44,6 +44,7 @@ int luat_bin_unpack(const char* binpath, int writeOut) {
     int ret = -1; // 返回值
     luat_bin_tlv_t* tlv = NULL; // TLV结构
     char path[64] = {0}; // 路径
+    size_t wsize = 0;
 
     size_t fsize = luat_fs_fsize(binpath);
     LLOGI("unpack path=%s size=%d", binpath, fsize);
@@ -81,8 +82,6 @@ int luat_bin_unpack(const char* binpath, int writeOut) {
     }
     // 跳过头部
     binbuff->offset += sizeof(luat_bin_tlv_t);
-    
-    size_t wsize = 0;
 
     // 开始解析主体
     while (1) {

+ 1 - 1
luat/packages/epaper/DEV_Config.c

@@ -37,7 +37,7 @@
 void DEV_SPI_WriteByte(UBYTE value)
 {
     //HAL_SPI_Transmit(&hspi1, &value, 1, 1000);
-    luat_spi_send(0, &value, 1);
+    luat_spi_send(0, (const char*)&value, 1);
 }
 
 int DEV_Module_Init(void)