From b8ff59700fbb33740e6e4d7e7f3419b4bdd082e7 Mon Sep 17 00:00:00 2001 From: Xu Xingliang Date: Fri, 2 Dec 2022 18:33:52 +0800 Subject: [PATCH] Fix compile warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit luv/src/fs.c:431:14: warning: declaration of ‘data’ shadows a previous local [-Wshadow] luv/src/private.h:114:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes] Signed-off-by: Xu Xingliang --- src/fs.c | 14 +++++++------- src/luv.h | 2 +- src/private.h | 2 +- src/thread.c | 2 +- src/work.c | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/fs.c b/src/fs.c index 27a9592f..917f13f1 100644 --- a/src/fs.c +++ b/src/fs.c @@ -428,14 +428,14 @@ static void luv_fs_cb(uv_fs_t* req) { // variable 'nargs' to the number of return values #define FS_CALL_NORETURN(func, req, ...) { \ int ret, sync; \ - luv_req_t* data = (luv_req_t*)req->data; \ - sync = data->callback_ref == LUA_NOREF; \ - ret = func(data->ctx->loop, req, __VA_ARGS__, \ + luv_req_t* lreq = (luv_req_t*)req->data; \ + sync = lreq->callback_ref == LUA_NOREF; \ + ret = func(lreq->ctx->loop, req, __VA_ARGS__, \ sync ? NULL : luv_fs_cb); \ if (req->fs_type != UV_FS_ACCESS && ret < 0) { \ lua_pushnil(L); \ if (fs_req_has_dest_path(req)) { \ - lua_rawgeti(L, LUA_REGISTRYINDEX, data->data_ref); \ + lua_rawgeti(L, LUA_REGISTRYINDEX, lreq->data_ref); \ const char* dest_path = lua_tostring(L, -1); \ lua_pop(L, 1); \ lua_pushfstring(L, "%s: %s: %s -> %s", \ @@ -455,7 +455,7 @@ static void luv_fs_cb(uv_fs_t* req) { } \ lua_pushstring(L, uv_err_name(req->result)); \ if(req->fs_type != UV_FS_SCANDIR) { \ - luv_cleanup_req(L, data); \ + luv_cleanup_req(L, lreq); \ req->data = NULL; \ uv_fs_req_cleanup(req); \ } \ @@ -464,13 +464,13 @@ static void luv_fs_cb(uv_fs_t* req) { else if (sync) { \ nargs = push_fs_result(L, req); \ if(req->fs_type != UV_FS_SCANDIR) { \ - luv_cleanup_req(L, data); \ + luv_cleanup_req(L, lreq); \ req->data = NULL; \ uv_fs_req_cleanup(req); \ } \ } \ else { \ - lua_rawgeti(L, LUA_REGISTRYINDEX, data->req_ref); \ + lua_rawgeti(L, LUA_REGISTRYINDEX, lreq->req_ref); \ nargs = 1; \ } \ } diff --git a/src/luv.h b/src/luv.h index 5921e15f..ad023291 100644 --- a/src/luv.h +++ b/src/luv.h @@ -147,7 +147,7 @@ LUALIB_API void luv_set_cthread(lua_State* L, luv_CFcpcall cpcall); */ LUALIB_API int luaopen_luv (lua_State *L); -typedef lua_State* (*luv_acquire_vm)(); +typedef lua_State* (*luv_acquire_vm)(void); typedef void (*luv_release_vm)(lua_State* L); LUALIB_API void luv_set_thread_cb(luv_acquire_vm acquire, luv_release_vm release); diff --git a/src/private.h b/src/private.h index 1e921a4a..b4ea7fba 100644 --- a/src/private.h +++ b/src/private.h @@ -111,7 +111,7 @@ static int luv_arg_type_error(lua_State* L, int index, const char* fmt); static int luv_optboolean(lua_State*L, int idx, int defaultval); /* From thread.c */ -static lua_State* luv_thread_acquire_vm(); +static lua_State* luv_thread_acquire_vm(void); /* From process.c */ static int luv_parse_signal(lua_State* L, int slot); diff --git a/src/thread.c b/src/thread.c index 36041af4..5de5556e 100644 --- a/src/thread.c +++ b/src/thread.c @@ -24,7 +24,7 @@ typedef struct { luv_thread_arg_t args; } luv_thread_t; -static lua_State* luv_thread_acquire_vm() { +static lua_State* luv_thread_acquire_vm(void) { lua_State* L = luaL_newstate(); // Add in the lua standard libraries diff --git a/src/work.c b/src/work.c index 7e42641f..b51bfd11 100644 --- a/src/work.c +++ b/src/work.c @@ -127,7 +127,7 @@ static int luv_work_cb(lua_State* L) { return LUA_OK; } -static lua_State* luv_work_acquire_vm() +static lua_State* luv_work_acquire_vm(void) { lua_State* L = uv_key_get(&tls_vmkey); if (L == NULL) @@ -245,7 +245,7 @@ static const luaL_Reg luv_work_ctx_methods[] = { {NULL, NULL} }; -static void luv_key_init_once() +static void luv_key_init_once(void) { const char* val; int status = uv_key_create(&tls_vmkey); @@ -287,7 +287,7 @@ static void luv_key_init_once() idx_vms = 0; } -static void luv_work_cleanup() +static void luv_work_cleanup(void) { unsigned int i;