Fix: src.ctf.fs: pointer arithmetics on non-adjacent memory
Issue
=====
When indexing a trace using `*.idx` files, if streams span more than one
packet the user may witness the following warning message:
W PLUGIN/SRC.CTF.FS/DS build_index_from_idx_file@data-stream-file.c:400
[source-ctf-fs] Invalid, non-monotonic, packet offset encountered in
LTTng trace index file: previous offset=
14757395258967641292, current offset=4096
This is caused by the fact the we're using pointer arithmetics to get
the pointer to the previous entry of an array. This ends returning
garbage because it's a pointer array and not a regular array storing the
objects as the code expects to.
This regression was most probably introduced by the following commit:
commit
7ed5243afe12c7c12fa5305fff99b93ad23bbdff
Author: Francis Deslauriers <francis.deslauriers@efficios.com>
Date: Wed May 15 14:59:10 2019 -0400
src.ctf.fs: merge all indexes to the fs_ds_group level
This problematic commit changes the `entries` fields of the `struct
ctf_fs_ds_index` from a `GArray *` to `GPtrArray * without changing the
pointer arithmetics.
This was not an error because indexing using `*.idx` files is optional
and indexing may fail back to direct packet indexing.
Solution
========
Use a local variable to store a pointer to the previous index_entry
rather than using pointer arithmetics.
Drawbacks
=========
None.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3e5608d0359be2a447e79415517068c64f5a2817
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1637
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>