]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/encoding: fix compat version error messages
authorSage Weil <sage@redhat.com>
Mon, 24 Apr 2017 17:41:24 +0000 (13:41 -0400)
committerSage Weil <sage@redhat.com>
Mon, 24 Apr 2017 18:27:47 +0000 (14:27 -0400)
These were just...wrong.  Correctly report the encoding version we
got and the oldest we can decode.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/encoding.h
src/test/encoding.cc

index 9ea25d316d1bed82e2d40804dd181778c0084e98..53f24e476f8c98f0b22d26c30d6631c5618b781d 100644 (file)
@@ -1063,11 +1063,8 @@ decode(std::array<T, N>& 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<T, N>& 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<T, N>& 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<T, N>& 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__)); \
index 29c3b99fddc3c8a5e5a88447a18c947372806f4f..135b55a5ce198e94b952b818141471c41db569f1 100644 (file)
@@ -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__));
   }
 }