From: Philippe Proulx Date: Thu, 3 Sep 2020 14:25:56 +0000 (-0400) Subject: barectf.c.j2: packet closing function: do not repeat member names X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=03088329f5d9c8c68e3f92b10767407cb4f04b73;p=deliverable%2Fbarectf.git barectf.c.j2: packet closing function: do not repeat member names Signed-off-by: Philippe Proulx --- 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' %}