Fix logic bug; we weren't checking last requirement in sort_deps.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Jul 2009 01:59:16 +0000 (11:29 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Jul 2009 01:59:16 +0000 (11:29 +0930)
ccan/tdb/tools/replay_trace.c

index bd4b8aa804eeaca2c11626cd659d4c7345ec73f4..652af3a4fbf79e9195e0eba05f4bbdcd96002c8b 100644 (file)
@@ -1088,6 +1088,10 @@ static bool sort_deps(char *filename[], struct op *op[],
        struct op *this_op;
        bool done[num_files];
 
+       /* None left?  We're sorted. */
+       if (off == num)
+               return true;
+
        /* Does this make serial numbers go backwards?  Allow a little fuzz. */
        if (off > 0) {
                int serial1 = op[res[off-1].file][res[off-1].op_num].serial;
@@ -1102,10 +1106,6 @@ static bool sort_deps(char *filename[], struct op *op[],
                }
        }
 
-       /* One or none left?  We're sorted. */
-       if (off + 1 >= num)
-               return true;
-
        memset(done, 0, sizeof(done));
 
        /* Since ops within a trace file are ordered, we just need to figure