From 03088329f5d9c8c68e3f92b10767407cb4f04b73 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 3 Sep 2020 10:25:56 -0400 Subject: [PATCH] barectf.c.j2: packet closing function: do not repeat member names Signed-off-by: Philippe Proulx --- barectf/templates/c/barectf.c.j2 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/barectf/templates/c/barectf.c.j2 b/barectf/templates/c/barectf.c.j2 index e27230e..1cfc436 100644 --- a/barectf/templates/c/barectf.c.j2 +++ b/barectf/templates/c/barectf.c.j2 @@ -326,8 +326,9 @@ void _commit_ev(void *vctx) /* save content size */ ctx->content_size = ctx->at; - {% if 'timestamp_end' in stream_type._pkt_ctx_ft.members %} - {% set op = stream_op_pkt_ctx_op(stream_type, 'timestamp_end') %} + {% set name = 'timestamp_end' %} + {% if name in stream_type._pkt_ctx_ft.members %} + {% set op = stream_op_pkt_ctx_op(stream_type, name) %} /* go back to `timestamp_end` field offset */ ctx->at = sctx->off_{{ c_common.op_src(op) }}; @@ -338,25 +339,27 @@ void _commit_ev(void *vctx) {% endfilter %} {% endif %} - {% if 'content_size' in stream_type._pkt_ctx_ft.members %} - {% set op = stream_op_pkt_ctx_op(stream_type, 'content_size') %} + {% set name = 'content_size' %} + {% if name in stream_type._pkt_ctx_ft.members %} + {% set op = stream_op_pkt_ctx_op(stream_type, name) %} /* go back to `content_size` field offset */ ctx->at = sctx->off_{{ c_common.op_src(op) }}; - {% set src = 'ctx->content_size' %} + {% set src %}ctx->{{ name }}{% endset %} {% filter indent_tab(indent_first=True) %} {% include 'c/serialize-write-saved-int-statements.j2' %} {% endfilter %} {% endif %} - {% if 'events_discarded' in stream_type._pkt_ctx_ft.members %} - {% set op = stream_op_pkt_ctx_op(stream_type, 'events_discarded') %} + {% set name = 'events_discarded' %} + {% if name in stream_type._pkt_ctx_ft.members %} + {% set op = stream_op_pkt_ctx_op(stream_type, name) %} /* go back to `events_discarded` field offset */ ctx->at = sctx->off_{{ c_common.op_src(op) }}; - {% set src = 'ctx->events_discarded' %} + {% set src %}ctx->{{ name }}{% endset %} {% filter indent_tab(indent_first=True) %} {% include 'c/serialize-write-saved-int-statements.j2' %} -- 2.34.1