]> git.cworth.org Git - apitrace/commitdiff
trim: Fix early-bailout bug when accepting both --calls and --frames
authorCarl Worth <cworth@cworth.org>
Mon, 11 Mar 2013 22:49:17 +0000 (15:49 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 12 Apr 2013 21:07:08 +0000 (14:07 -0700)
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

index b0cb8f167557fbe162b174a50ddf2610ce905b2b..13436705dbe71aebe982e34b4b818311255c7e20 100644 (file)
@@ -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;
         }