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 <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2026-05-05 15:08:35 -05:00
parent eacb27b4cf
commit 0d86cd5ce5
2 changed files with 8 additions and 1 deletions

View file

@ -23,9 +23,11 @@
* SOFTWARE.
*/
#include "config.h"
#include <libweston/libweston.h>
#include "perfetto/annotations.h"
#include "shared/weston-assert.h"
#include "weston-trace.h"
WL_EXPORT int
@ -34,6 +36,8 @@ perfetto_annotate_int(struct weston_debug_annotation *annots,
const char *key,
int value)
{
weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, count);
annots[count].type = WESTON_DEBUG_ANNOTATION_INT_VAL;
annots[count].ivalue = value;
annots[count].key = key;
@ -47,6 +51,8 @@ perfetto_annotate_float(struct weston_debug_annotation *annots,
const char *key,
float value)
{
weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, count);
annots[count].type = WESTON_DEBUG_ANNOTATION_FLOAT_VAL;
annots[count].fvalue = value;
annots[count].key = key;
@ -60,6 +66,8 @@ perfetto_annotate_string(struct weston_debug_annotation *annots,
const char *key,
const char *value)
{
weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, count);
annots[count].type = WESTON_DEBUG_ANNOTATION_STR_VAL;
annots[count].svalue = value;
annots[count].key = key;

View file

@ -79,7 +79,6 @@
unsigned int __pd_i = 0
#define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \
weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, __pd_i); \
__pd_i += _Generic((v), \
int: perfetto_annotate_int, \
unsigned int: perfetto_annotate_int, \