From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (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 82D694696C0 for ; Tue, 10 Dec 2019 12:49:26 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id m6so19132019ljc.1 for ; Tue, 10 Dec 2019 01:49:26 -0800 (PST) From: Cyrill Gorcunov Date: Tue, 10 Dec 2019 12:48:52 +0300 Message-Id: <20191210094855.24953-3-gorcunov@gmail.com> In-Reply-To: <20191210094855.24953-1-gorcunov@gmail.com> References: <20191210094855.24953-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 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