From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 7D090430409 for ; Thu, 3 Sep 2020 11:07:17 +0300 (MSK) References: <20200901103143.31898-1-i.kosarev@tarantool.org> From: Aleksandr Lyapunov Message-ID: <13d8a0b3-88c0-1c96-aae9-330975c6e090@tarantool.org> Date: Thu, 3 Sep 2020 11:07:16 +0300 MIME-Version: 1.0 In-Reply-To: <20200901103143.31898-1-i.kosarev@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ilya Kosarev Cc: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org Hi! thanks for the patch, LGTM On 01.09.2020 13:31, Ilya Kosarev wrote: > MsgPack extension types allow applications to define > application-specific types. They consist of an 8-bit signed integer and > a byte array where the integer represents a kind of types and the byte > array represents data. Types from 0 to 127 are application-specific > types and types from -128 to -1 are reserved for predefined types. > However, extension types were printed as unsigned integers. Now it is > fixed and extension types are being printed in a correct way as signed > integers. Also the typo in word "Unsupported" was fixed. According test > case is introduced. > > Closes #5016 > --- > Branch: https://github.com/tarantool/tarantool/tree/i.kosarev/gh-5016-fix-extension-decoding > Issue: https://github.com/tarantool/tarantool/issues/5016 > > src/box/lua/init.c | 2 +- > src/lua/msgpack.c | 2 +- > test/app-tap/msgpack.test.lua | 11 ++++++++--- > 3 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/src/box/lua/init.c b/src/box/lua/init.c > index cac62b958d..d0316ef867 100644 > --- a/src/box/lua/init.c > +++ b/src/box/lua/init.c > @@ -431,7 +431,7 @@ luamp_decode_extension_box(struct lua_State *L, const char **data) > uint32_t len = mp_decode_extl(data, &ext_type); > > if (ext_type != MP_ERROR) { > - luaL_error(L, "Unsuported MsgPack extension type: %u", > + luaL_error(L, "Unsupported MsgPack extension type: %d", > ext_type); > return; > } > diff --git a/src/lua/msgpack.c b/src/lua/msgpack.c > index 128cc5d2ff..4c4ada39cb 100644 > --- a/src/lua/msgpack.c > +++ b/src/lua/msgpack.c > @@ -94,7 +94,7 @@ luamp_decode_extension_default(struct lua_State *L, const char **data) > { > int8_t ext_type; > mp_decode_extl(data, &ext_type); > - luaL_error(L, "msgpack.decode: unsupported extension: %u", ext_type); > + luaL_error(L, "msgpack.decode: unsupported extension: %d", ext_type); > } > > > diff --git a/test/app-tap/msgpack.test.lua b/test/app-tap/msgpack.test.lua > index 2d62850fb3..3f7ca2c3e7 100755 > --- a/test/app-tap/msgpack.test.lua > +++ b/test/app-tap/msgpack.test.lua > @@ -36,7 +36,7 @@ local function test_offsets(test, s) > end > > local function test_misc(test, s) > - test:plan(5) > + test:plan(8) > local ffi = require('ffi') > local buffer = require('buffer') > local buf = ffi.cast("const char *", "\x91\x01") > @@ -48,8 +48,13 @@ local function test_misc(test, s) > test:is_deeply(result, {1}, "ibuf_decode result") > test:ok(not st and e:match("null"), "null ibuf") > st, e = pcall(s.decode, "\xd4\x0f\x00") > - test:ok(not st and e:match("Unsuported MsgPack extension type: 15"), > - "unsupported extension decode") > + test:is(e, "Unsupported MsgPack extension type: 15", > + "decode result for \\xd4\\x0f\\x00: " .. e) > + test:ok(not st, "unsupported extension decode") > + st, e = pcall(s.decode, "\xd4\xfe\x00") > + test:is(e, "Unsupported MsgPack extension type: -2", > + "decode result for \\xd4\\xfe\\x00: " .. e) > + test:ok(not st, "unsupported extension decode") > end > > local function test_decode_array_map_header(test, s)