From: Sage Weil Date: Mon, 24 Apr 2017 17:41:24 +0000 (-0400) Subject: include/encoding: fix compat version error messages X-Git-Tag: v12.0.3~190^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86e195cbe65c6058a6f4087cf0b6bd4182eb97bd;p=ceph.git include/encoding: fix compat version error messages These were just...wrong. Correctly report the encoding version we got and the oldest we can decode. Signed-off-by: Sage Weil --- diff --git a/src/include/encoding.h b/src/include/encoding.h index 9ea25d316d1b..53f24e476f8c 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -1063,11 +1063,8 @@ decode(std::array& v, bufferlist::iterator& p) #define ENCODE_FINISH(bl) ENCODE_FINISH_NEW_COMPAT(bl, 0) -#define DECODE_ERR_VERSION(func, v) \ - (std::string(func) + " unknown encoding version > " #v) - -#define DECODE_ERR_OLDVERSION(func, v) \ - (std::string(func) + " no longer understand old encoding version < " #v) +#define DECODE_ERR_OLDVERSION(func, v, compatv) \ + (std::string(func) + " no longer understand old encoding version " #v " < " #compatv) #define DECODE_ERR_PAST(func) \ (std::string(func) + " decode past end of struct encoding") @@ -1081,7 +1078,7 @@ decode(std::array& v, bufferlist::iterator& p) */ #define DECODE_OLDEST(oldestv) \ if (struct_v < oldestv) \ - throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, v)); + throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, v, oldestv)); /** * start a decoding block @@ -1094,7 +1091,7 @@ decode(std::array& v, bufferlist::iterator& p) ::decode(struct_v, bl); \ ::decode(struct_compat, bl); \ if (v < struct_compat) \ - throw buffer::malformed_input(DECODE_ERR_VERSION(__PRETTY_FUNCTION__, v)); \ + throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, v, struct_compat)); \ __u32 struct_len; \ ::decode(struct_len, bl); \ if (struct_len > bl.get_remaining()) \ @@ -1109,7 +1106,7 @@ decode(std::array& v, bufferlist::iterator& p) __u8 struct_compat; \ ::decode(struct_compat, bl); \ if (v < struct_compat) \ - throw buffer::malformed_input(DECODE_ERR_VERSION(__PRETTY_FUNCTION__, v)); \ + throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, v, struct_compat)); \ } else if (skip_v) { \ if ((int)bl.get_remaining() < skip_v) \ throw buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); \ diff --git a/src/test/encoding.cc b/src/test/encoding.cc index 29c3b99fddc3..135b55a5ce19 100644 --- a/src/test/encoding.cc +++ b/src/test/encoding.cc @@ -292,18 +292,15 @@ TEST(EncodingRoundTrip, Integers) { } const char* expected_what[] = { - "buffer::malformed_input: void lame_decoder(int) unknown encoding version > 100", - "buffer::malformed_input: void lame_decoder(int) no longer understand old encoding version < 100", + "buffer::malformed_input: void lame_decoder(int) no longer understand old encoding version 100 < 200", "buffer::malformed_input: void lame_decoder(int) decode past end of struct encoding", }; void lame_decoder(int which) { switch (which) { case 0: - throw buffer::malformed_input(DECODE_ERR_VERSION(__PRETTY_FUNCTION__, 100)); + throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, 100, 200)); case 1: - throw buffer::malformed_input(DECODE_ERR_OLDVERSION(__PRETTY_FUNCTION__, 100)); - case 2: throw buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); } }