From: Mathieu Desnoyers Date: Wed, 7 Apr 2021 16:01:15 +0000 (-0400) Subject: Fix: pass private data to context callbacks X-Git-Tag: v2.13.0-rc1~149 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6ba6fd60507f8e045bdc4f1be14e9d99c6a15f7f;p=lttng-ust.git Fix: pass private data to context callbacks commit 4e48b5d2debaf ("Refactoring: add back constness of public API structures") changes the type of the first argument received by context callbacks from a struct lttng_ust_ctx_field pointer to a void private data pointer. That commit failed to change some call sites, which were still passing the struct lttng_ust_ctx_field pointer rather than the private data pointer. This was not caught by compiler errors because we are loosening from a structure pointer to a void pointer. Fixes: #1303 Signed-off-by: Mathieu Desnoyers Change-Id: I653f454b5dc4cfcc229b3a0e17b2dc6abe9fd658 --- diff --git a/liblttng-ust/lttng-context.c b/liblttng-ust/lttng-context.c index 0aaae755..7043c157 100644 --- a/liblttng-ust/lttng-context.c +++ b/liblttng-ust/lttng-context.c @@ -234,7 +234,7 @@ void lttng_destroy_context(struct lttng_ust_ctx *ctx) return; for (i = 0; i < ctx->nr_fields; i++) { if (ctx->fields[i].destroy) - ctx->fields[i].destroy(&ctx->fields[i]); + ctx->fields[i].destroy(ctx->fields[i].priv); } free(ctx->fields); free(ctx); diff --git a/liblttng-ust/lttng-ring-buffer-client-template.h b/liblttng-ust/lttng-ring-buffer-client-template.h index f8348ba4..a63786bc 100644 --- a/liblttng-ust/lttng-ring-buffer-client-template.h +++ b/liblttng-ust/lttng-ring-buffer-client-template.h @@ -108,7 +108,7 @@ void ctx_get_struct_size(struct lttng_ust_ctx *ctx, size_t *ctx_len) return; } for (i = 0; i < ctx->nr_fields; i++) - offset += ctx->fields[i].get_size(&ctx->fields[i], offset); + offset += ctx->fields[i].get_size(ctx->fields[i].priv, offset); *ctx_len = offset; } @@ -123,7 +123,7 @@ void ctx_record(struct lttng_ust_lib_ring_buffer_ctx *bufctx, return; lttng_ust_lib_ring_buffer_align_ctx(bufctx, ctx->largest_align); for (i = 0; i < ctx->nr_fields; i++) - ctx->fields[i].record(&ctx->fields[i], bufctx, chan); + ctx->fields[i].record(ctx->fields[i].priv, bufctx, chan); } /*