From c55444795d9a008b87d73b55c10060daa50dcfc7 Mon Sep 17 00:00:00 2001 From: Paul Wagener Date: Sat, 21 Feb 2015 16:13:34 +0100 Subject: [PATCH 1/2] Invert boolean output of router_result_to_plan() `check_plan_invariants()` returns *true* if there is a fail, while `router_result_to_plan()` returns *false* if there is a fail. Hence the need to invert the output before returning. --- router_result.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router_result.c b/router_result.c index 8a03723..e8455f8 100644 --- a/router_result.c +++ b/router_result.c @@ -316,7 +316,7 @@ bool router_result_to_plan (plan_t *plan, router_t *router, router_request_t *re plan->n_itineraries += 1; itin += 1; } - return check_plan_invariants (plan); + return !check_plan_invariants (plan); } /* After routing, call to convert the router state into a readable list of From 4e61b9ff862024086ba9ebb7378d63ef8d2a5d69 Mon Sep 17 00:00:00 2001 From: Paul Wagener Date: Sat, 21 Feb 2015 16:47:45 +0100 Subject: [PATCH 2/2] Added braces to checks in check_plan_invariants() These prevent every single plan from failing the invariants checking. --- router_result.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/router_result.c b/router_result.c index e8455f8..27760b1 100644 --- a/router_result.c +++ b/router_result.c @@ -144,11 +144,15 @@ static bool check_plan_invariants (plan_t *plan) { for (i_leg = 0; i_leg < itin->n_legs; ++i_leg) { leg_t *leg = itin->legs + i_leg; if (i_leg % 2 == 0) { - if (leg->journey_pattern != WALK) fprintf(stderr, "even numbered leg %d has journey_pattern %d not WALK.\n", i_leg, leg->journey_pattern); - fail = true; + if (leg->journey_pattern != WALK) { + fprintf(stderr, "even numbered leg %d has journey_pattern %d not WALK.\n", i_leg, leg->journey_pattern); + fail = true; + } } else { - if (leg->journey_pattern == WALK) fprintf(stderr, "odd numbered leg %d has journey_pattern WALK.\n", i_leg); - fail = true; + if (leg->journey_pattern == WALK) { + fprintf(stderr, "odd numbered leg %d has journey_pattern WALK.\n", i_leg); + fail = true; + } } if (leg->t1 < leg->t0) { fprintf(stderr, "non-increasing times within leg %d: %d, %d\n", i_leg, leg->t0, leg->t1);