From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 E682D4696C3 for ; Sun, 12 Apr 2020 17:15:19 +0300 (MSK) References: <20200408153339.GF5713@tarantool.org> <9c602d2d-9963-b8f3-46a9-eacaf1a94278@tarantool.org> <20200411093858.GH5713@tarantool.org> <66c72a67-ccbc-c2b3-ce84-df27a32d69ab@tarantool.org> <20200411181128.GI5713@tarantool.org> From: Vladislav Shpilevoy Message-ID: <2ee28a74-f044-4783-2843-aa41505b34b2@tarantool.org> Date: Sun, 12 Apr 2020 16:15:16 +0200 MIME-Version: 1.0 In-Reply-To: <20200411181128.GI5713@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 >>> 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. > > OK, thanks, got it. It might be useful to drop a couple words regarding > it. Feel free to ignore. Done: ==================== diff --git a/src/box/lua/console.c b/src/box/lua/console.c index c647c39d7..b941f50c6 100644 --- a/src/box/lua/console.c +++ b/src/box/lua/console.c @@ -465,10 +465,16 @@ 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) + if (data == NULL) { assert(port->plain == NULL); - else + } else { + /* + * Result is ignored, because in case of an error + * port->plain will stay NULL. And it will be + * returned by port_msgpack_dump_plain() as is. + */ port_msgpack_set_plain((struct port *)port, data, *size); + } return 0; } @@ -493,6 +499,10 @@ port_msgpack_dump_plain(struct port *base, uint32_t *size) lua_pop(L, 1); return NULL; } + /* + * If there was an error, port->plain stayed NULL with + * installed diag. + */ return ((struct port_msgpack *)base)->plain; } ====================