Skip to content

Commit

Permalink
askrene: fix CI
Browse files Browse the repository at this point in the history
check the return value of scanf in askrene unit tests,

Changelog-none: askrene: fix CI

Signed-off-by: Lagrang3 <[email protected]>
  • Loading branch information
Lagrang3 authored and rustyrussell committed Nov 21, 2024
1 parent 937cf7a commit ee62361
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/askrene/mcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static double get_median_ratio(const tal_t *working_ctx,
size_t n = 0;

for (struct arc arc = {.idx=0};arc.idx < max_num_arcs; ++arc.idx) {
if (arc_is_dual(graph, arc) || !arc_enabled(graph, arc))
if (arc_is_dual(graph, arc))
continue;
assert(n < max_num_arcs/2);
u64_arr[n] = linear_network->arc_fee_cost[arc.idx];
Expand Down
13 changes: 8 additions & 5 deletions plugins/askrene/test/run-mcf-large.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ static int next_bit(s64 x)

static bool solve_case(const tal_t *ctx)
{
int ret;
static int c = 0;
c++;
tal_t *this_ctx = tal(ctx, tal_t);

int N_nodes, N_arcs;
myscanf("%d %d\n", &N_nodes, &N_arcs);
ret = myscanf("%d %d\n", &N_nodes, &N_arcs);
CHECK(ret == 2);
printf("Testcase %d\n", c);
printf("nodes %d arcs %d\n", N_nodes, N_arcs);
if (N_nodes == 0 && N_arcs == 0)
Expand All @@ -75,9 +77,9 @@ static bool solve_case(const tal_t *ctx)

for (u32 i = 0; i < N_arcs; i++) {
u32 from, to;
myscanf("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64, &from,
&to, &capacity[i], &cost[i]);

ret = myscanf("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64,
&from, &to, &capacity[i], &cost[i]);
CHECK(ret == 4);
struct arc arc = {.idx = i};
graph_add_arc(graph, arc, node_obj(from), node_obj(to));

Expand All @@ -89,7 +91,8 @@ static bool solve_case(const tal_t *ctx)
struct node dst = {.idx = 1};

s64 amount, best_cost;
myscanf("%" PRIi64 " %" PRIi64, &amount, &best_cost);
ret = myscanf("%" PRIi64 " %" PRIi64, &amount, &best_cost);
CHECK(ret == 2);

bool result = simple_mcf(ctx, graph, src, dst, capacity, amount, cost);
CHECK(result);
Expand Down

0 comments on commit ee62361

Please sign in to comment.