Fix: pass private data to context callbacks
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Apr 2021 16:01:15 +0000 (12:01 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Apr 2021 16:06:54 +0000 (12:06 -0400)
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 <mathieu.desnoyers@efficios.com>
Change-Id: I653f454b5dc4cfcc229b3a0e17b2dc6abe9fd658

liblttng-ust/lttng-context.c
liblttng-ust/lttng-ring-buffer-client-template.h

index 0aaae755cc35b324b2a77a083306acea890010cc..7043c1571d78b00fe555bc38756fd54f992e4aa7 100644 (file)
@@ -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);
index f8348ba4c90dce595b3a4c41a0a505960abc96c3..a63786bc892ea93c990e7e3144a246f51c10a526 100644 (file)
@@ -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);
 }
 
 /*
This page took 0.03661 seconds and 4 git commands to generate.