From 18198bc20331e48f45fc0c36cb3f256a58e24e4b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 11 Mar 2013 15:49:17 -0700 Subject: [PATCH] trim: Fix early-bailout bug when accepting both --calls and --frames The trim code was inappropriately bailing once either list was exhausted, before also exhausting the user's other requested list. This fixes the traces/trim-frames-and-calls test recently added to the apitrace-tests repository. Thanks to Eric Anholt for reporting this bug. --- cli/cli_trim.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/cli_trim.cpp b/cli/cli_trim.cpp index b0cb8f1..1343670 100644 --- a/cli/cli_trim.cpp +++ b/cli/cli_trim.cpp @@ -196,11 +196,11 @@ trim_trace(const char *filename, struct trim_options *options) trace::Call *call; while ((call = p.parse_call())) { - /* There's no use doing any work past the last call or frame + /* There's no use doing any work past the last call and frame * requested by the user. */ - if (call->no > options->calls.getLast() || - frame > options->frames.getLast()) { - + if ((options->calls.empty() || call->no > options->calls.getLast()) && + (options->frames.empty() || frame > options->frames.getLast())) { + delete call; break; } @@ -264,10 +264,10 @@ trim_trace(const char *filename, struct trim_options *options) call_range_last = -1; while ((call = p.parse_call())) { - /* There's no use doing any work past the last call or frame + /* There's no use doing any work past the last call and frame * requested by the user. */ - if (call->no > options->calls.getLast() || - frame > options->frames.getLast()) { + if ((options->calls.empty() || call->no > options->calls.getLast()) && + (options->frames.empty() || frame > options->frames.getLast())) { break; } -- 2.43.0