From: Julien Desfossez Date: Wed, 14 Jun 2017 18:21:27 +0000 (-0400) Subject: fs-sink: packet_context is optional X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=8aa557db53e12d6cde0e49ba76ba4c9cf0144d5c fs-sink: packet_context is optional Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/fs-sink/write.c b/plugins/ctf/fs-sink/write.c index a3cc5c8b..6413108b 100644 --- a/plugins/ctf/fs-sink/write.c +++ b/plugins/ctf/fs-sink/write.c @@ -649,6 +649,7 @@ enum bt_component_status writer_new_packet( { struct bt_ctf_stream *stream = NULL, *writer_stream = NULL; struct bt_ctf_field *writer_packet_context = NULL; + struct bt_ctf_field *packet_context = NULL; enum bt_component_status ret = BT_COMPONENT_STATUS_OK; int int_ret; @@ -667,20 +668,24 @@ enum bt_component_status writer_new_packet( } BT_PUT(stream); - writer_packet_context = ctf_copy_packet_context(writer_component->err, - packet, writer_stream); - if (!writer_packet_context) { - fprintf(writer_component->err, "[error] %s in %s:%d\n", - __func__, __FILE__, __LINE__); - goto error; - } + packet_context = bt_ctf_packet_get_context(packet); + if (packet_context) { + writer_packet_context = ctf_copy_packet_context( + writer_component->err, packet, writer_stream); + if (!writer_packet_context) { + fprintf(writer_component->err, "[error] %s in %s:%d\n", + __func__, __FILE__, __LINE__); + goto error; + } + BT_PUT(packet_context); - int_ret = bt_ctf_stream_set_packet_context(writer_stream, - writer_packet_context); - if (int_ret < 0) { - fprintf(writer_component->err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); - goto error; + int_ret = bt_ctf_stream_set_packet_context(writer_stream, + writer_packet_context); + if (int_ret < 0) { + fprintf(writer_component->err, "[error] %s in %s:%d\n", __func__, + __FILE__, __LINE__); + goto error; + } } BT_PUT(writer_stream); BT_PUT(writer_packet_context); @@ -691,6 +696,7 @@ error: ret = BT_COMPONENT_STATUS_ERROR; end: bt_put(writer_stream); + bt_put(packet_context); bt_put(writer_packet_context); bt_put(stream); return ret;