[PATCH] Use msgpack_pack_v4raw(_body) with new msgpack-c versions
authorJames McCoy <jamessan@jamessan.com>
Wed, 15 Jun 2016 13:26:20 +0000 (09:26 -0400)
committerAndrii Senkovych <andrii@senkovych.com>
Sun, 26 Aug 2018 12:30:36 +0000 (13:30 +0100)
In msgpack-c's 1.0.0 release, the code was changed to be compatible with
the v5 msgpack spec, specifically separating out the STR and BIN types
as replacements for the old RAW type.

While the STR type is likely the right replacement type to use, it does
introduce a str 8 variant that wasn't present for the old RAW type.  For
better compatibility, the msgpack_pack_v4raw functions were added to
directly map to the old functionality.

Signed-off-by: James McCoy <jamessan@jamessan.com>
Gbp-Pq: Name msgpack-compat.patch

formats/msgpack.c

index dc1ab0c4023493920cc69d757c56d55d6ba24c09..a3abc8b6eba913c01185cca4bed221309b02910e 100644 (file)
@@ -8,6 +8,18 @@
 #include <hiredis/hiredis.h>
 #include <hiredis/async.h>
 
+/* msgpack-c versions >= 1.0 changed to support the v5 msgpack spec.
+ * As part of doing this, the (un)pack_raw functions were replaced with
+ * more explicit (un)pack_str and (un)pack_bin.  1.2.0 introduced the
+ * (un)pack_v4raw functions to retain compatibility.
+ */
+#if defined(MSGPACK_VERSION_MAJOR) && defined(MSGPACK_VERSION_MINOR) \
+       && MSGPACK_VERSION_MAJOR > 1 \
+       || (MSGPACK_VERSION_MAJOR == 1 && MSGPACK_VERSION_MINOR >= 2)
+#define msgpack_pack_raw msgpack_pack_v4raw
+#define msgpack_pack_raw_body msgpack_pack_v4raw_body
+#endif
+
 struct msg_out {
        char *p;
        size_t sz;