From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 91B2C4696C3 for ; Sat, 11 Apr 2020 21:11:08 +0300 (MSK) References: <20200408153339.GF5713@tarantool.org> <9c602d2d-9963-b8f3-46a9-eacaf1a94278@tarantool.org> <20200411093858.GH5713@tarantool.org> From: Vladislav Shpilevoy Message-ID: <66c72a67-ccbc-c2b3-ce84-df27a32d69ab@tarantool.org> Date: Sat, 11 Apr 2020 20:11:06 +0200 MIME-Version: 1.0 In-Reply-To: <20200411093858.GH5713@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v2 1/1] box: export box_session_push to the public C API List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the review! >> diff --git a/src/box/lua/console.c b/src/box/lua/console.c >> index 886120eac..ff2db5832 100644 >> --- a/src/box/lua/console.c >> +++ b/src/box/lua/console.c >> @@ -461,11 +465,10 @@ port_msgpack_dump_plain_via_lua(struct lua_State *L) >> */ >> luamp_decode(L, luaL_msgpack_default, &data); >> data = console_dump_plain(L, size); >> - if (data == NULL) { >> - *result = NULL; >> - return 0; >> - } >> - *result = port_mspack_set_plain((struct port *)port, data, *size); >> + if (data == NULL) >> + assert(port->plain == NULL); >> + else >> + port_mspack_set_plain((struct port *)port, data, *size); > > Typo: s/port_mspack_set_plain/port_msgpack_set_plain/g. Thanks, fixed: ==================== diff --git a/src/box/call.c b/src/box/call.c index 599df7f60..7c70d8169 100644 --- a/src/box/call.c +++ b/src/box/call.c @@ -91,7 +91,7 @@ port_msgpack_destroy(struct port *base) } int -port_mspack_set_plain(struct port *base, const char *plain, uint32_t len) +port_msgpack_set_plain(struct port *base, const char *plain, uint32_t len) { struct port_msgpack *port = (struct port_msgpack *)base; assert(port->plain == NULL); diff --git a/src/box/lua/console.c b/src/box/lua/console.c index ff2db5832..c647c39d7 100644 --- a/src/box/lua/console.c +++ b/src/box/lua/console.c @@ -468,7 +468,7 @@ port_msgpack_dump_plain_via_lua(struct lua_State *L) if (data == NULL) assert(port->plain == NULL); else - port_mspack_set_plain((struct port *)port, data, *size); + port_msgpack_set_plain((struct port *)port, data, *size); return 0; } diff --git a/src/box/port.h b/src/box/port.h index 32d13f589..fa6c1374d 100644 --- a/src/box/port.h +++ b/src/box/port.h @@ -108,7 +108,7 @@ port_msgpack_destroy(struct port *base); * Set plain text version of data in the given port. It is copied. */ int -port_mspack_set_plain(struct port *base, const char *plain, uint32_t len); +port_msgpack_set_plain(struct port *base, const char *plain, uint32_t len); /** Port for storing the result of a Lua CALL/EVAL. */ struct port_lua { ==================== > The result value is not checked, but returns -1 > when OOM occurs. No need to check result. port_mspack_set_plain() not only returns -1, it also keeps port->plain NULL. If it is NULL, it is an error. port_mspack_dump_plain() returns port->plain. Therefore if there was an error, it will return NULL with a correctly installed diag.