*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
#include <stdlib.h>
struct ctf_file_stream **cfsp,
uint64_t *max_timestamp)
{
- int ret = EOF, i;
+ int ret = EOF, i, found = 0;
for (i = 0; i < stream_class->streams->len; i++) {
struct ctf_stream_definition *stream;
if (current_max_ts >= *max_timestamp) {
*max_timestamp = current_max_ts;
*cfsp = cfs;
+ found = 1;
}
}
assert(ret >= 0 || ret == EOF);
+ if (found) {
+ return 0;
+ }
return ret;
}
stream->prev_cycles_timestamp = 0;
stream->prev_cycles_timestamp_end = 0;
- printf_debug("restored to cur_index = %zd and "
- "offset = %zd, timestamp = %" PRIu64 "\n",
+ printf_debug("restored to cur_index = %" PRId64 " and "
+ "offset = %" PRId64 ", timestamp = %" PRIu64 "\n",
stream_pos->cur_index,
stream_pos->offset, stream->real_timestamp);
if (ret != 0 && ret != EOF) {
goto error;
}
+ if (ret == EOF) {
+ /* Do not add EOF streams */
+ continue;
+ }
ret = heap_insert(iter->stream_heap, file_stream);
if (ret)
goto error;
break;
case BT_SEEK_LAST:
{
- struct ctf_file_stream *cfs;
+ struct ctf_file_stream *cfs = NULL;
tc = iter->ctx->tc;
ret = seek_last_ctf_trace_collection(tc, &cfs);
- if (ret != 0)
+ if (ret != 0 || !cfs)
goto error;
/* remove all streams from the heap */
heap_free(iter->stream_heap);
break;
case BT_SEEK_TIME:
case BT_SEEK_RESTORE:
- case BT_SEEK_END:
default:
assert(0); /* Not yet defined */
}