[Tarantool-patches] [PATCH 2/5] lua/fio: Add lbox_fio_push_error as a separate helper
Cyrill Gorcunov
gorcunov at gmail.com
Thu Nov 28 23:45:09 MSK 2019
Since lbox_fio_pushbool always push boolean first
it is inpossible to use it inside other routines.
Thus make a separate helper lbox_fio_push_error
which will be used in popen code later.
Part-of #4031
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
src/lua/fio.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/lua/fio.c b/src/lua/fio.c
index 7437cc0c6..33ccd5d71 100644
--- a/src/lua/fio.c
+++ b/src/lua/fio.c
@@ -52,6 +52,16 @@
luaT_push_nil_and_error(L); \
})
+static inline int
+lbox_fio_push_error(struct lua_State *L)
+{
+ diag_set(SystemError, "fio: %s", strerror(errno));
+ struct error *e = diag_last_error(diag_get());
+ assert(e != NULL);
+ luaT_pusherror(L, e);
+ return 1;
+}
+
static int
lbox_fio_open(struct lua_State *L)
{
@@ -118,10 +128,7 @@ lbox_fio_pushbool(struct lua_State *L, bool res)
{
lua_pushboolean(L, res);
if (!res) {
- diag_set(SystemError, "fio: %s", strerror(errno));
- struct error *e = diag_last_error(diag_get());
- assert(e != NULL);
- luaT_pusherror(L, e);
+ lbox_fio_push_error(L);
return 2;
}
return 1;
--
2.20.1
More information about the Tarantool-patches
mailing list