Fix: `ctf` plugin: do not have an `mdec` variable where not strictly needed
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 19:54:48 +0000 (15:54 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 21 Jun 2019 18:02:01 +0000 (14:02 -0400)
commit3c8252a5b96d617770863d3f54398b58d4c3315a
treebbe8ac5f78b8ac96129aeebdf911556561398769
parentd2d857a8c492de2cde82d191a20c50b43842bdd7
Fix: `ctf` plugin: do not have an `mdec` variable where not strictly needed

Issue
=====
The `metadata-info` query needs to call
ctf_metadata_decoder_packetized_file_stream_to_buf() with a custom log
level and no self component (`NULL`). Eventually, this reaches
decode_packet() which is in the `decoder.c` file and thus uses
`mdec->self_comp` to find its self component in the BT_COMP_LOG*()
macros. But in this case, `mdec` is `NULL`, so there's an invalid
memory access.

Solution
========
Instead of using BT_COMP_LOG_CUR_LVL() everywhere in this function, and
because decode_packet() and
ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec() do not
strictly need `mdec` except for logging its address at some places, move
the functions to the new `decoder-packetized-file-stream-to-buf.c` file
and make them not accept an `mdec` argument.

This new file's logging uses the local `log_level` and `self_comp`
variables, so the logging statement are not modified.

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I55874790b2b873ff1718a774e57011300e57518d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1526
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/common/metadata/Makefile.am
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder.c
src/plugins/ctf/common/metadata/decoder.h
src/plugins/ctf/fs-src/query.c
This page took 0.025004 seconds and 4 git commands to generate.