* [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer
@ 2020-09-04 13:55 Ilya Kosarev
0 siblings, 0 replies; 4+ messages in thread
From: Ilya Kosarev @ 2020-09-04 13:55 UTC (permalink / raw)
To: kyukhin; +Cc: tarantool-patches
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
@ChangeLog:
* Fix msgpack extension types decoding error message (gh-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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer
2020-09-01 10:31 Ilya Kosarev
2020-09-03 8:07 ` Aleksandr Lyapunov
@ 2020-09-08 14:51 ` Kirill Yukhin
1 sibling, 0 replies; 4+ messages in thread
From: Kirill Yukhin @ 2020-09-08 14:51 UTC (permalink / raw)
To: Ilya Kosarev; +Cc: tarantool-patches, alexander.turenko
Hello,
On 01 сен 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
I've checked your patch into 2.4, 2.5 and master.
--
Regards, Kirill Yukhin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer
2020-09-01 10:31 Ilya Kosarev
@ 2020-09-03 8:07 ` Aleksandr Lyapunov
2020-09-08 14:51 ` Kirill Yukhin
1 sibling, 0 replies; 4+ messages in thread
From: Aleksandr Lyapunov @ 2020-09-03 8:07 UTC (permalink / raw)
To: Ilya Kosarev; +Cc: tarantool-patches, alexander.turenko
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer
@ 2020-09-01 10:31 Ilya Kosarev
2020-09-03 8:07 ` Aleksandr Lyapunov
2020-09-08 14:51 ` Kirill Yukhin
0 siblings, 2 replies; 4+ messages in thread
From: Ilya Kosarev @ 2020-09-01 10:31 UTC (permalink / raw)
To: alyapunov; +Cc: tarantool-patches, alexander.turenko
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-08 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 13:55 [Tarantool-patches] [PATCH] msgpack: print mp_exp type as signed integer Ilya Kosarev
-- strict thread matches above, loose matches on Subject: below --
2020-09-01 10:31 Ilya Kosarev
2020-09-03 8:07 ` Aleksandr Lyapunov
2020-09-08 14:51 ` Kirill Yukhin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox