From e4d1ab0c19d1d7edc119c0996b428a37ad1a54a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sun, 5 Nov 2023 04:12:30 +0100 Subject: [PATCH] spa: debug: log: use `SPA_CONTAINER_OF()` Use `SPA_CONTAINER_OF()` instead of direct casting as it is more resilient against future changes that might reorder the members in `struct spa_debug_log_ctx`. --- spa/include/spa/debug/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/include/spa/debug/log.h b/spa/include/spa/debug/log.h index 43b3bd52b..aa16c5e9e 100644 --- a/spa/include/spa/debug/log.h +++ b/spa/include/spa/debug/log.h @@ -38,7 +38,7 @@ struct spa_debug_log_ctx { SPA_PRINTF_FUNC(2,3) static inline void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...) { - struct spa_debug_log_ctx *c = (struct spa_debug_log_ctx*)ctx; + struct spa_debug_log_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_log_ctx, ctx); va_list args; va_start(args, fmt); spa_log_logtv(c->log, c->level, c->topic, c->file, c->line, c->func, fmt, args);