From 94c037416577d196d7396a3365f8ff88ffac6e37 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 19 May 2018 17:39:26 +0300 Subject: [PATCH] Fixed the union code generation: if the union contained a power of two number of items, the tag bit length was one higher than needed, causing incorrect serialization. --- .../libuavcan_dsdl_compiler/data_type_template.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl index 2b0acbf8e9..3107426bf0 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl @@ -70,7 +70,7 @@ struct UAVCAN_EXPORT ${t.cpp_type_name} }; }; - typedef ::uavcan::IntegerSpec< ::uavcan::IntegerBitLen< ${len(fields)} >::Result, + typedef ::uavcan::IntegerSpec< ::uavcan::IntegerBitLen< ${len(fields)}U - 1U >::Result, ::uavcan::SignednessUnsigned, ::uavcan::CastModeTruncate > TagType; #! enum_name, enum_comparator