Преглед изворни кода

update: 清除一些编译警告,主要是配合bsp/mini的

Wendal Chen пре 2 година
родитељ
комит
430e6b0fad

+ 1 - 0
components/crypto/luat_crypto_mbedtls.c

@@ -386,6 +386,7 @@ int luat_crypto_cipher_suites(const char** list, size_t* len) {
     }
     }
     *len = count;
     *len = count;
 #else
 #else
+    (void)list;
     *len = 0;
     *len = 0;
 #endif
 #endif
     return 0;
     return 0;

+ 8 - 8
components/lua-cjson/lua_cjson.c

@@ -437,10 +437,10 @@ static void json_encode_exception(lua_State *l, strbuf_t *json, int lindex,
  * Returns nothing. Doesn't remove string from Lua stack */
  * Returns nothing. Doesn't remove string from Lua stack */
 static void json_append_string(lua_State *l, strbuf_t *json, int lindex)
 static void json_append_string(lua_State *l, strbuf_t *json, int lindex)
 {
 {
-    const char *escstr;
-    int i;
-    const char *str;
-    size_t len;
+    const char *escstr = NULL;
+    size_t i = 0;
+    const char *str = NULL;
+    size_t len = 0;
 
 
     str = lua_tolstring(l, lindex, &len);
     str = lua_tolstring(l, lindex, &len);
 
 
@@ -1363,7 +1363,7 @@ static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup)
     lua_pop(l, nup);  /* remove upvalues */
     lua_pop(l, nup);  /* remove upvalues */
 }
 }
 #endif
 #endif
-
+#if 0
 /* Call target function in protected mode with all supplied args.
 /* Call target function in protected mode with all supplied args.
  * Assumes target function only returns a single non-nil value.
  * Assumes target function only returns a single non-nil value.
  * Convert and return thrown errors as: nil, "error message" */
  * Convert and return thrown errors as: nil, "error message" */
@@ -1391,7 +1391,7 @@ static int json_protect_conversion(lua_State *l)
      * errors are memory related */
      * errors are memory related */
     return luaL_error(l, "Memory allocation error in CJSON protected call");
     return luaL_error(l, "Memory allocation error in CJSON protected call");
 }
 }
-
+#endif
 /*
 /*
 将对象序列化为json字符串
 将对象序列化为json字符串
 @api json.encode(obj,t)
 @api json.encode(obj,t)
@@ -1411,8 +1411,8 @@ static int l_json_encode_safe(lua_State *L) {
     }
     }
     memcpy(float_fmt, "%.7g", strlen("%.7g") + 1);
     memcpy(float_fmt, "%.7g", strlen("%.7g") + 1);
     size_t len = 0;
     size_t len = 0;
-	int prec = 0;
-    char buff[6] = {0};
+	// int prec = 0;
+    // char buff[6] = {0};
 	if (lua_isstring(L, 2)) {
 	if (lua_isstring(L, 2)) {
 		const char* mode = luaL_checklstring(L, 2, &len);
 		const char* mode = luaL_checklstring(L, 2, &len);
         //LLOGD("json format ? %s", mode);
         //LLOGD("json format ? %s", mode);

+ 2 - 2
components/lua-cjson/strbuf.h

@@ -110,12 +110,12 @@ static inline void strbuf_extend_length(strbuf_t *s, int len)
 {
 {
     s->length += len;
     s->length += len;
 }
 }
-
+#if 0
 static inline int strbuf_length(strbuf_t *s)
 static inline int strbuf_length(strbuf_t *s)
 {
 {
     return s->length;
     return s->length;
 }
 }
-
+#endif
 static inline void strbuf_append_char(strbuf_t *s, const char c)
 static inline void strbuf_append_char(strbuf_t *s, const char c)
 {
 {
     strbuf_ensure_empty_length(s, 1);
     strbuf_ensure_empty_length(s, 1);

+ 1 - 0
components/rsa/binding/luat_lib_rsa.c

@@ -53,6 +53,7 @@ end
 #include "mbedtls/md.h"
 #include "mbedtls/md.h"
 
 
 static int myrand( void *rng_state, unsigned char *output, size_t len ) {
 static int myrand( void *rng_state, unsigned char *output, size_t len ) {
+    (void)rng_state;
     luat_crypto_trng((char*)output, len);
     luat_crypto_trng((char*)output, len);
     return 0;
     return 0;
 }
 }

+ 1 - 1
luat/modules/crc.c

@@ -61,7 +61,7 @@ BOOL input_reverse; //输入数据反转
 BOOL output_reverse; //输出数据反转
 BOOL output_reverse; //输出数据反转
 } crc16method;
 } crc16method;
 
 
-const static crc16method crc16method_table[] = 
+static const crc16method crc16method_table[] = 
 {
 {
     {(const char*)"IBM", 0x8005, 0x0000, 0x0000, TRUE, TRUE},
     {(const char*)"IBM", 0x8005, 0x0000, 0x0000, TRUE, TRUE},
     {(const char*)"MAXIM", 0x8005, 0x0000, 0xffff, TRUE, TRUE}, 
     {(const char*)"MAXIM", 0x8005, 0x0000, 0xffff, TRUE, TRUE}, 

+ 1 - 0
luat/modules/luat_base.c

@@ -130,6 +130,7 @@ int luat_cbcwait(lua_State *L, uint64_t id, int arg_num) {
 --此为系统内部使用的消息,请勿在外部使用
 --此为系统内部使用的消息,请勿在外部使用
 */
 */
 static int luat_cbcwait_cb(lua_State *L, void* ptr) {
 static int luat_cbcwait_cb(lua_State *L, void* ptr) {
+    (void)ptr;
     rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
     rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
     if(lua_getglobal(L, "sys_pub") != LUA_TFUNCTION)
     if(lua_getglobal(L, "sys_pub") != LUA_TFUNCTION)
         return 0;
         return 0;

+ 1 - 1
luat/modules/luat_lib_crypto.c

@@ -689,7 +689,7 @@ static int l_crypt_hash_init(lua_State *L) {
         memset(stream, 0x00, sizeof(luat_crypt_stream_t));
         memset(stream, 0x00, sizeof(luat_crypt_stream_t));
         const char* key = NULL;
         const char* key = NULL;
         const char* md = luaL_checkstring(L, 1);
         const char* md = luaL_checkstring(L, 1);
-        strncpy(stream->tp, md, strlen(md));
+        memcpy(stream->tp, md, strlen(md)+1);
         if(lua_type(L, 2) == LUA_TSTRING) {
         if(lua_type(L, 2) == LUA_TSTRING) {
             key = luaL_checklstring(L, 2, &(stream->key_len));
             key = luaL_checklstring(L, 2, &(stream->key_len));
         }
         }

+ 32 - 3
luat/vfs/luat_fs_posix.c

@@ -117,11 +117,13 @@ int luat_fs_rmdir(char const* _DirName) {
 
 
 FILE* luat_vfs_posix_fopen(void* userdata, const char *filename, const char *mode) {
 FILE* luat_vfs_posix_fopen(void* userdata, const char *filename, const char *mode) {
     //LLOGD("fopen %s %s", filename + FILENAME_OFFSET, mode);
     //LLOGD("fopen %s %s", filename + FILENAME_OFFSET, mode);
+    (void)userdata;
     return fopen(filename + FILENAME_OFFSET, mode);
     return fopen(filename + FILENAME_OFFSET, mode);
 }
 }
 
 
 int luat_vfs_posix_getc(void* userdata, FILE* stream) {
 int luat_vfs_posix_getc(void* userdata, FILE* stream) {
     //LLOGD("posix_getc %p", stream);
     //LLOGD("posix_getc %p", stream);
+    (void)userdata;
     #ifdef LUAT_FS_NO_POSIX_GETC
     #ifdef LUAT_FS_NO_POSIX_GETC
     uint8_t buff = 0;
     uint8_t buff = 0;
     int ret = luat_fs_fread(&buff, 1, 1, stream);
     int ret = luat_fs_fread(&buff, 1, 1, stream);
@@ -135,33 +137,41 @@ int luat_vfs_posix_getc(void* userdata, FILE* stream) {
 }
 }
 
 
 int luat_vfs_posix_fseek(void* userdata, FILE* stream, long int offset, int origin) {
 int luat_vfs_posix_fseek(void* userdata, FILE* stream, long int offset, int origin) {
+    (void)userdata;
     return fseek(stream, offset, origin);
     return fseek(stream, offset, origin);
 }
 }
 
 
 int luat_vfs_posix_ftell(void* userdata, FILE* stream) {
 int luat_vfs_posix_ftell(void* userdata, FILE* stream) {
+    (void)userdata;
     return ftell(stream);
     return ftell(stream);
 }
 }
 
 
 int luat_vfs_posix_fclose(void* userdata, FILE* stream) {
 int luat_vfs_posix_fclose(void* userdata, FILE* stream) {
+    (void)userdata;
     return fclose(stream);
     return fclose(stream);
 }
 }
 int luat_vfs_posix_feof(void* userdata, FILE* stream) {
 int luat_vfs_posix_feof(void* userdata, FILE* stream) {
+    (void)userdata;
     return feof(stream);
     return feof(stream);
 }
 }
 int luat_vfs_posix_ferror(void* userdata, FILE *stream) {
 int luat_vfs_posix_ferror(void* userdata, FILE *stream) {
+    (void)userdata;
     return ferror(stream);
     return ferror(stream);
 }
 }
 size_t luat_vfs_posix_fread(void* userdata, void *ptr, size_t size, size_t nmemb, FILE *stream) {
 size_t luat_vfs_posix_fread(void* userdata, void *ptr, size_t size, size_t nmemb, FILE *stream) {
-    
+    (void)userdata;
     return fread(ptr, size, nmemb, stream);
     return fread(ptr, size, nmemb, stream);
 }
 }
 size_t luat_vfs_posix_fwrite(void* userdata, const void *ptr, size_t size, size_t nmemb, FILE *stream) {
 size_t luat_vfs_posix_fwrite(void* userdata, const void *ptr, size_t size, size_t nmemb, FILE *stream) {
+    (void)userdata;
     return fwrite(ptr, size, nmemb, stream);
     return fwrite(ptr, size, nmemb, stream);
 }
 }
 int luat_vfs_posix_remove(void* userdata, const char *filename) {
 int luat_vfs_posix_remove(void* userdata, const char *filename) {
+    (void)userdata;
     return remove(filename + FILENAME_OFFSET);
     return remove(filename + FILENAME_OFFSET);
 }
 }
 int luat_vfs_posix_rename(void* userdata, const char *old_filename, const char *new_filename) {
 int luat_vfs_posix_rename(void* userdata, const char *old_filename, const char *new_filename) {
+    (void)userdata;
 #if LUA_USE_VFS_FILENAME_OFFSET
 #if LUA_USE_VFS_FILENAME_OFFSET
     return rename(old_filename + (old_filename[0] == '/' ? 1 : 0), new_filename + (new_filename[0] == '/' ? 1 : 0));
     return rename(old_filename + (old_filename[0] == '/' ? 1 : 0), new_filename + (new_filename[0] == '/' ? 1 : 0));
 #else
 #else
@@ -190,14 +200,20 @@ size_t luat_vfs_posix_fsize(void* userdata, const char *filename) {
 }
 }
 
 
 int luat_vfs_posix_mkfs(void* userdata, luat_fs_conf_t *conf) {
 int luat_vfs_posix_mkfs(void* userdata, luat_fs_conf_t *conf) {
+    (void)userdata;
+    (void)conf;
     LLOGE("not support yet : mkfs");
     LLOGE("not support yet : mkfs");
     return -1;
     return -1;
 }
 }
 int luat_vfs_posix_mount(void** userdata, luat_fs_conf_t *conf) {
 int luat_vfs_posix_mount(void** userdata, luat_fs_conf_t *conf) {
+    (void)userdata;
+    (void)conf;
     //LLOGE("not support yet : mount");
     //LLOGE("not support yet : mount");
     return 0;
     return 0;
 }
 }
 int luat_vfs_posix_umount(void* userdata, luat_fs_conf_t *conf) {
 int luat_vfs_posix_umount(void* userdata, luat_fs_conf_t *conf) {
+    (void)userdata;
+    (void)conf;
     //LLOGE("not support yet : umount");
     //LLOGE("not support yet : umount");
     return 0;
     return 0;
 }
 }
@@ -206,16 +222,22 @@ int luat_vfs_posix_umount(void* userdata, luat_fs_conf_t *conf) {
 #include <stdio.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #endif
 #endif
 
 
 int luat_vfs_posix_mkdir(void* userdata, char const* _DirName) {
 int luat_vfs_posix_mkdir(void* userdata, char const* _DirName) {
-#if defined(LUA_USE_LINUX) || defined(LUA_USE_WINDOWS) || defined(LUA_USE_MACOSX)
+    (void)userdata;
+#if defined(LUA_USE_WINDOWS)
     return mkdir(_DirName);
     return mkdir(_DirName);
+#elif defined(LUA_USE_LINUX) || defined(LUA_USE_MACOSX)
+    return mkdir(_DirName, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
 #else
 #else
     return -1;
     return -1;
 #endif
 #endif
 }
 }
 int luat_vfs_posix_rmdir(void* userdata, char const* _DirName) {
 int luat_vfs_posix_rmdir(void* userdata, char const* _DirName) {
+    (void)userdata;
 #if defined(LUA_USE_LINUX) || defined(LUA_USE_WINDOWS) || defined(LUA_USE_MACOSX)
 #if defined(LUA_USE_LINUX) || defined(LUA_USE_WINDOWS) || defined(LUA_USE_MACOSX)
     return rmdir(_DirName);
     return rmdir(_DirName);
 #else
 #else
@@ -223,7 +245,9 @@ int luat_vfs_posix_rmdir(void* userdata, char const* _DirName) {
 #endif
 #endif
 }
 }
 int luat_vfs_posix_info(void* userdata, const char* path, luat_fs_info_t *conf) {
 int luat_vfs_posix_info(void* userdata, const char* path, luat_fs_info_t *conf) {
-
+    (void)userdata;
+    (void)path;
+    (void)conf;
     memcpy(conf->filesystem, "posix", strlen("posix")+1);
     memcpy(conf->filesystem, "posix", strlen("posix")+1);
     conf->type = 0;
     conf->type = 0;
     conf->total_block = 0;
     conf->total_block = 0;
@@ -234,6 +258,7 @@ int luat_vfs_posix_info(void* userdata, const char* path, luat_fs_info_t *conf)
 
 
 #if defined(LUA_USE_LINUX) || defined(LUA_USE_WINDOWS) || defined(LUA_USE_MACOSX)
 #if defined(LUA_USE_LINUX) || defined(LUA_USE_WINDOWS) || defined(LUA_USE_MACOSX)
 int luat_vfs_posix_lsdir(void* fsdata, char const* _DirName, luat_fs_dirent_t* ents, size_t offset, size_t len) {
 int luat_vfs_posix_lsdir(void* fsdata, char const* _DirName, luat_fs_dirent_t* ents, size_t offset, size_t len) {
+    (void)fsdata;
     DIR *dp;
     DIR *dp;
     struct dirent *ep;
     struct dirent *ep;
     int index = 0;
     int index = 0;
@@ -251,12 +276,16 @@ int luat_vfs_posix_lsdir(void* fsdata, char const* _DirName, luat_fs_dirent_t* e
             }
             }
             if (len > 0) {
             if (len > 0) {
                 memcpy(ents[index].d_name, ep->d_name, strlen(ep->d_name) + 1);
                 memcpy(ents[index].d_name, ep->d_name, strlen(ep->d_name) + 1);
+                #ifdef LUA_USE_WINDOWS
+                ents[index].d_type = 0;
+                #else
                 if (ep->d_type == DT_REG) {
                 if (ep->d_type == DT_REG) {
                     ents[index].d_type = 0;
                     ents[index].d_type = 0;
                 }
                 }
                 else {
                 else {
                     ents[index].d_type = 1;
                     ents[index].d_type = 1;
                 }
                 }
+                #endif
                 index++;
                 index++;
                 len --;
                 len --;
             }
             }