Feedback Corrections for LuaUnixPrctl

This commit is contained in:
Yael 2023-04-09 17:00:55 +03:00 committed by GitHub
parent 8320b37490
commit da887b56ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3213,7 +3213,7 @@ static int LuaUnixMount(lua_State *L) {
// unix.umount(target: str[, flags: int) // unix.umount(target: str[, flags: int)
// ├─→ true // ├─→ true
// ├─→ nil, unix.Errorno // ├─→ nil, unix.Errrno
static int LuaUnixUnmount(lua_State *L) { static int LuaUnixUnmount(lua_State *L) {
int olderr = errno; int olderr = errno;
return SysretBool( return SysretBool(
@ -3223,45 +3223,42 @@ static int LuaUnixUnmount(lua_State *L) {
// unix.prctl(option: int[, arg2: int[, arg3: int[, arg4: int[, arg5: int]]]]) // unix.prctl(option: int[, arg2: int[, arg3: int[, arg4: int[, arg5: int]]]])
// ├─→ result: int // ├─→ result: int
// ├─→ nil, unix.Errorno // └─→ nil, unix.Errno
static int LuaUnixPrctl(lua_State *L) { static int LuaUnixPrctl(lua_State *L) {
int olderr; int olderr;
int option; int option;
int status;
unsigned long arg2 = 0, arg3 = 0, arg4 = 0, arg5 = 0; unsigned long arg2 = 0, arg3 = 0, arg4 = 0, arg5 = 0;
olderr = errno; olderr = errno;
option = luaL_checkinteger(L, 1); option = luaL_checkinteger(L, 1);
if (lua_gettop(L) >= 2) { if (lua_gettop(L) >= 2) {
if (lua_isnumber(L, 2)) { arg2 = lua_tointegerx(L, 2, &status);
arg2 = lua_tointeger(L, 2); if (!status) {
} else if (lua_isstring(L, 2)) { arg2 = (unsigned long)lua_tostring(L, 2);
arg2 = (unsigned long) lua_tostring(L, 2); }
} }
}
if (lua_gettop(L) >= 3) { if (lua_gettop(L) >= 3) {
if (lua_isnumber(L, 3)) { arg3 = lua_tointegerx(L, 3, &status);
arg3 = lua_tointeger(L, 3); if (!status) {
} else if (lua_isstring(L, 3)) { arg3 = (unsigned long)lua_tostring(L, 3);
arg3 = (unsigned long) lua_tostring(L, 3); }
} }
}
if (lua_gettop(L) >= 4) { if (lua_gettop(L) >= 4) {
if (lua_isnumber(L, 4)) { arg4 = lua_tointegerx(L, 4, &status);
arg4 = lua_tointeger(L, 4); if (!status) {
} else if (lua_isstring(L, 4)) { arg4 = (unsigned long)lua_tostring(L, 4);
arg4 = (unsigned long) lua_tostring(L, 4); }
} }
}
if (lua_gettop(L) >= 5) { if (lua_gettop(L) >= 5) {
if (lua_isnumber(L, 5)) { arg5 = lua_tointegerx(L, 5, &status);
arg5 = lua_tointeger(L, 5); if (!status) {
} else if (lua_isstring(L, 5)) { arg5 = (unsigned long)lua_tostring(L, 5);
arg5 = (unsigned long) lua_tostring(L, 5); }
} }
}
return SysretInteger( return SysretInteger(
L, "prctl", olderr, L, "prctl", olderr,
prctl(option, arg2, arg3, arg4, arg5)); prctl(option, arg2, arg3, arg4, arg5));