From: Mathieu Desnoyers Date: Wed, 17 Aug 2022 19:10:58 +0000 (-0400) Subject: Fix: disable array/sequence compile-time type check in C X-Git-Tag: v2.13.4~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5542c10ea61f7bc7e6bc3b0f57b5ff3f02feb61e;p=lttng-ust.git Fix: disable array/sequence compile-time type check in C Disable this compile-time check in C. Indeed, the C implementation of lttng_ust_is_pointer_type does not support opaque pointer types, because it relies on pointer arithmetic. Therefore, remove this check to keep supporting opaque pointers as array/sequence elements in probe providers. The worse that could happen is that users providing an unsupported type as array/sequence element will end up with a meaningless integer field. Signed-off-by: Mathieu Desnoyers Change-Id: I0fa170f7af7fc016027685e48076ebaf0366cc5b --- diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 1edb50c1..7771518a 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -257,9 +257,16 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG }; #include LTTNG_UST_TRACEPOINT_INCLUDE +#if defined(__cplusplus) + /* * Stage 0.9.1 - * Verifying array and sequence elements are of an integer type. + * Verifying array and sequence elements are of an integer or pointer + * type. + * + * This compile-time check is only enabled in C++, because the C + * implementation of lttng_ust_is_pointer_type does not support opaque + * pointer types. */ /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ @@ -288,6 +295,8 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG #include LTTNG_UST_TRACEPOINT_INCLUDE +#endif + /* * Stage 0.9.2 of tracepoint event generation. * diff --git a/include/lttng/ust-utils.h b/include/lttng/ust-utils.h index 7cb0ea34..2d55b61f 100644 --- a/include/lttng/ust-utils.h +++ b/include/lttng/ust-utils.h @@ -62,6 +62,9 @@ * lttng_ust_is_pointer_type - check if type is a pointer * * Returns true if the type of @type is a pointer. + * + * Note: The C implementation of lttng_ust_is_pointer_type uses pointer + * arithmetic, which does not work on opaque pointer types. */ #if defined(__cplusplus) #define lttng_ust_is_pointer_type(type) (std::is_pointer::value)