From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (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 6E0F84696C0 for ; Wed, 11 Dec 2019 12:29:04 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id z17so23174354ljk.13 for ; Wed, 11 Dec 2019 01:29:04 -0800 (PST) From: Cyrill Gorcunov Date: Wed, 11 Dec 2019 12:28:30 +0300 Message-Id: <20191211092833.12212-3-gorcunov@gmail.com> In-Reply-To: <20191211092833.12212-1-gorcunov@gmail.com> References: <20191211092833.12212-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v3 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