From ca63358821e899808105139f157acf9a113ac392 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Mon, 10 Jun 2019 12:30:10 -0400 Subject: [PATCH] Fix: src.ctf.fs: increment packet offset before init of index entry Issue ===== The `current_packet_offset_bytes` variable is incremented before the initialization of the current `index_entry` by `init_index_entry()`. This lead to each entry having the offset of the next entry and the last entry having a erroneous offset. Solution ======== Increment the `current_packet_offset_bytes` variable after the initialization of each entry. Drawbacks ========= None. Signed-off-by: Francis Deslauriers Change-Id: I7592b2d70f402aa413de97a687bfe4fe1bf1b825 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1409 Tested-by: jenkins Reviewed-by: Philippe Proulx --- plugins/ctf/fs-src/data-stream-file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index e89f0719..99d3b472 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -564,12 +564,6 @@ struct ctf_fs_ds_index *build_index_from_stream_file( goto error; } - current_packet_offset_bytes += current_packet_size_bytes; - BT_LOGD("Seeking to next packet: current-packet-offset=%jd, " - "next-packet-offset=%jd", - current_packet_offset_bytes - current_packet_size_bytes, - current_packet_offset_bytes); - index_entry = g_new0(struct ctf_fs_ds_index_entry, 1); if (!index_entry) { BT_LOGE_STR("Failed to allocate a new index entry."); @@ -585,6 +579,12 @@ struct ctf_fs_ds_index *build_index_from_stream_file( g_ptr_array_add(index->entries, index_entry); + current_packet_offset_bytes += current_packet_size_bytes; + BT_LOGD("Seeking to next packet: current-packet-offset=%jd, " + "next-packet-offset=%jd", + current_packet_offset_bytes - current_packet_size_bytes, + current_packet_offset_bytes); + } while (iter_status == BT_MSG_ITER_STATUS_OK); if (iter_status != BT_MSG_ITER_STATUS_OK) { -- 2.34.1