From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D333E4696C0 for ; Thu, 28 Nov 2019 23:45:50 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id u17so2334812lja.4 for ; Thu, 28 Nov 2019 12:45:50 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 28 Nov 2019 23:45:09 +0300 Message-Id: <20191128204512.19732-3-gorcunov@gmail.com> In-Reply-To: <20191128204512.19732-1-gorcunov@gmail.com> References: <20191128204512.19732-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/5] lua/fio: Add lbox_fio_push_error as a separate helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml 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 --- 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