From 5ead8fc3a68738c1569ec635f898f50f9476bf4a Mon Sep 17 00:00:00 2001 From: Xu Xingliang Date: Mon, 12 Dec 2022 11:56:58 +0800 Subject: [PATCH] fix compile warnings Signed-off-by: Xu Xingliang --- src/fs.c | 14 +++++++------- src/luv.h | 2 +- src/private.h | 2 +- src/thread.c | 4 ++-- src/work.c | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/fs.c b/src/fs.c index 344d602..ea2a80a 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 = uv_fs_##func(data->ctx->loop, req, __VA_ARGS__, \ + luv_req_t* lreq = (luv_req_t*)req->data; \ + sync = lreq->callback_ref == LUA_NOREF; \ + ret = uv_fs_##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 5921e15..ad02329 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 1e921a4..b4ea7fb 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 36041af..93427d4 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 @@ -262,7 +262,7 @@ static int luv_thread_gc(lua_State* L) { static int luv_thread_tostring(lua_State* L) { luv_thread_t* thd = luv_check_thread(L, 1); - lua_pushfstring(L, "uv_thread_t: %p", (void*)thd->handle); + lua_pushfstring(L, "uv_thread_t: %p", (void*)(uintptr_t)thd->handle); return 1; } diff --git a/src/work.c b/src/work.c index b6b7561..52d8004 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) @@ -247,7 +247,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); @@ -289,7 +289,7 @@ static void luv_key_init_once() idx_vms = 0; } -static void luv_work_cleanup() +static void luv_work_cleanup(void) { unsigned int i; -- 2.25.1