Tarantool development patches archive
 help / color / mirror / Atom feed
From: Ilya Kosarev <i.kosarev@tarantool.org>
To: alyapunov@tarantool.org
Cc: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org
Subject: [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer
Date: Tue,  1 Sep 2020 13:31:43 +0300	[thread overview]
Message-ID: <20200901103143.31898-1-i.kosarev@tarantool.org> (raw)

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)
-- 
2.17.1

             reply	other threads:[~2020-09-01 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 10:31 Ilya Kosarev [this message]
2020-09-03  8:07 ` Aleksandr Lyapunov
2020-09-08 14:51 ` Kirill Yukhin
2020-09-04 13:55 Ilya Kosarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901103143.31898-1-i.kosarev@tarantool.org \
    --to=i.kosarev@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox