From: Olivier Dion Date: Thu, 21 Mar 2024 18:51:07 +0000 (-0400) Subject: ust-tracepoint-event: Add static check of sequences length type X-Git-Tag: v2.13.8~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9261aeadea4674c3d68e05c2e8fcbcefa54feb56;p=lttng-ust.git ust-tracepoint-event: Add static check of sequences length type Enforce required unsigned type for length of sequence at compile time. Change-Id: Ia8668a80eb0c0b81e8c03b208d7581e34af313fd Signed-off-by: Olivier Dion Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 97117d90..bd67a4ca 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -257,6 +257,38 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG }; #include LTTNG_UST_TRACEPOINT_INCLUDE + +/* + * Stage 0.9.0 + * Verifying sequence length types are of an unsigned type. + */ + +/* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ +#include +#include +#include + +/* + * Note that it is not possible to encode the length type as a C identifier, + * since it can be multiple tokens. + */ +#undef lttng_ust__field_sequence_encoded +#define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, \ + _length_type, _src_length, _encoding, _nowrite, \ + _elem_type_base) \ + lttng_ust_static_assert(!lttng_ust_is_signed_type(_length_type), \ + "Length type " #_length_type " is not a unsigned integer type", \ + Length_type_is_not_a_unsigned_integer_type); + +#undef LTTNG_UST_TP_FIELDS +#define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ + +#undef LTTNG_UST__TRACEPOINT_EVENT_CLASS +#define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ + _fields + +#include LTTNG_UST_TRACEPOINT_INCLUDE + #if defined(__cplusplus) /*