treewide: avoid lua_tonumber where integer is expected

parent c06010be
......@@ -129,7 +129,7 @@ static int cache_max_ttl(lua_State *L)
if (!lua_isnumber(L, 1))
lua_error_p(L, "expected 'max_ttl(number ttl)'");
uint32_t min = cache->ttl_min;
int64_t ttl = lua_tonumber(L, 1);
int64_t ttl = lua_tointeger(L, 1);
if (ttl < 0 || ttl < min || ttl > UINT32_MAX) {
lua_error_p(L,
"max_ttl must be larger than minimum TTL, and in range <1, "
......@@ -151,7 +151,7 @@ static int cache_min_ttl(lua_State *L)
if (!lua_isnumber(L, 1))
lua_error_p(L, "expected 'min_ttl(number ttl)'");
uint32_t max = cache->ttl_max;
int64_t ttl = lua_tonumber(L, 1);
int64_t ttl = lua_tointeger(L, 1);
if (ttl < 0 || ttl > max || ttl > UINT32_MAX) {
lua_error_p(L,
"min_ttl must be smaller than maximum TTL, and in range <0, "
......@@ -174,7 +174,7 @@ static int cache_open(lua_State *L)
/* Select cache storage backend */
struct engine *engine = engine_luaget(L);
lua_Number csize_lua = lua_tonumber(L, 1);
lua_Number csize_lua = lua_tointeger(L, 1);
if (!(csize_lua >= 8192 && csize_lua < SIZE_MAX)) { /* min. is basically arbitrary */
lua_error_p(L, "invalid cache size specified, it must be in range <8192, "
STR(SIZE_MAX) ">");
......
......@@ -104,7 +104,7 @@ static int event_after(lua_State *L)
if (n < 2 || !lua_isnumber(L, 1) || !lua_isfunction(L, 2))
lua_error_p(L, "expected 'after(number timeout, function)'");
return event_sched(L, lua_tonumber(L, 1), 0);
return event_sched(L, lua_tointeger(L, 1), 0);
}
static int event_recurrent(lua_State *L)
......@@ -114,7 +114,7 @@ static int event_recurrent(lua_State *L)
if (n < 2 || !lua_isnumber(L, 1) || !lua_isfunction(L, 2))
lua_error_p(L, "expected 'recurrent(number interval, function)'");
return event_sched(L, 0, lua_tonumber(L, 1));
return event_sched(L, 0, lua_tointeger(L, 1));
}
static int event_cancel(lua_State *L)
......@@ -183,7 +183,7 @@ static int event_fdwatch(lua_State *L)
lua_error_p(L, "out of memory");
/* Start timer with the reference */
int sock = lua_tonumber(L, 1);
int sock = lua_tointeger(L, 1);
uv_loop_t *loop = uv_default_loop();
#if defined(__APPLE__) || defined(__FreeBSD__)
/* libuv is buggy and fails to create poller for
......
......@@ -91,7 +91,7 @@ static inline int l_ffi_call(lua_State *L, int argc)
return kr_error(EIO);
}
if (lua_isnumber(L, -1)) { /* Return code */
status = lua_tonumber(L, -1);
status = lua_tointeger(L, -1);
} else if (lua_isthread(L, -1)) { /* Continuations */
status = l_ffi_defer(lua_tothread(L, -1));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment