From b4df8bd9e5ccbe2342113545e169c3f6da6c7a10 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 5 May 2026 15:08:35 -0500 Subject: [PATCH] trace: Move assertions into individual annotation functions The int, string, and float annotators will become our atoms when we start logging larger structs. The functions for complex annotations will call these many times for a single annotation. So we should assert in the int, string, and float annotators before adding there, so the big functions are implicitly checked. Signed-off-by: Derek Foreman --- libweston/perfetto/annotations.c | 5 +++++ libweston/weston-trace.h | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libweston/perfetto/annotations.c b/libweston/perfetto/annotations.c index 1f3e3f3c8..79571a4aa 100644 --- a/libweston/perfetto/annotations.c +++ b/libweston/perfetto/annotations.c @@ -23,9 +23,11 @@ * SOFTWARE. */ +#include "config.h" #include #include "perfetto/annotations.h" +#include "shared/weston-assert.h" #include "weston-trace.h" WL_EXPORT void @@ -33,6 +35,7 @@ perfetto_annotate_int(struct weston_debug_annotations *annots, const char *key, int value) { + weston_assert_u8_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, annots->count); struct weston_debug_annotation *annot = &annots->annots[annots->count]; annot->type = WESTON_DEBUG_ANNOTATION_INT_VAL; @@ -47,6 +50,7 @@ perfetto_annotate_float(struct weston_debug_annotations *annots, const char *key, float value) { + weston_assert_u8_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, annots->count); struct weston_debug_annotation *annot = &annots->annots[annots->count]; annot->type = WESTON_DEBUG_ANNOTATION_FLOAT_VAL; @@ -61,6 +65,7 @@ perfetto_annotate_string(struct weston_debug_annotations *annots, const char *key, const char *value) { + weston_assert_u8_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, annots->count); struct weston_debug_annotation *annot = &annots->annots[annots->count]; annot->type = WESTON_DEBUG_ANNOTATION_STR_VAL; diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index a3b9b3b57..34731770b 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -82,7 +82,6 @@ } #define _WESTON_TRACE_ANNOTATE_ADD_GENERIC(k, v) \ - weston_assert_u8_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, __pd_annots.count); \ _Generic((v), \ int: perfetto_annotate_int, \ unsigned int: perfetto_annotate_int, \