#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")
*/
#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
::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()) \
__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__)); \
}
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__));
}
}