Skip to content

Commit 917a48d

Browse files
committed
askrene: fix CI
check the return value of scanf in askrene unit tests, Changelog-none: askrene: fix CI Signed-off-by: Lagrang3 <[email protected]>
1 parent 6d6e280 commit 917a48d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

plugins/askrene/mcf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static double get_median_ratio(const tal_t *working_ctx,
450450
size_t n = 0;
451451

452452
for (struct arc arc = {.idx=0};arc.idx < max_num_arcs; ++arc.idx) {
453-
if (arc_is_dual(graph, arc) || !arc_enabled(graph, arc))
453+
if (arc_is_dual(graph, arc))
454454
continue;
455455
assert(n < max_num_arcs/2);
456456
u64_arr[n] = linear_network->arc_fee_cost[arc.idx];

plugins/askrene/test/run-mcf-large.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ static int next_bit(s64 x)
3636

3737
static bool solve_case(const tal_t *ctx)
3838
{
39+
int ret;
3940
static int c = 0;
4041
c++;
4142
tal_t *this_ctx = tal(ctx, tal_t);
4243

4344
int N_nodes, N_arcs;
44-
myscanf("%d %d\n", &N_nodes, &N_arcs);
45+
ret = myscanf("%d %d\n", &N_nodes, &N_arcs);
46+
CHECK(ret == 2);
4547
printf("Testcase %d\n", c);
4648
printf("nodes %d arcs %d\n", N_nodes, N_arcs);
4749
if (N_nodes == 0 && N_arcs == 0)
@@ -60,9 +62,9 @@ static bool solve_case(const tal_t *ctx)
6062

6163
for (u32 i = 0; i < N_arcs; i++) {
6264
u32 from, to;
63-
myscanf("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64, &from,
64-
&to, &capacity[i], &cost[i]);
65-
65+
ret = myscanf("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64,
66+
&from, &to, &capacity[i], &cost[i]);
67+
CHECK(ret == 4);
6668
struct arc arc = {.idx = i};
6769
graph_add_arc(graph, arc, node_obj(from), node_obj(to));
6870

@@ -74,7 +76,8 @@ static bool solve_case(const tal_t *ctx)
7476
struct node dst = {.idx = 1};
7577

7678
s64 amount, best_cost;
77-
myscanf("%" PRIi64 " %" PRIi64, &amount, &best_cost);
79+
ret = myscanf("%" PRIi64 " %" PRIi64, &amount, &best_cost);
80+
CHECK(ret == 2);
7881

7982
bool result = simple_mcf(ctx, graph, src, dst, capacity, amount, cost);
8083
CHECK(result);
@@ -99,7 +102,8 @@ static bool solve_case(const tal_t *ctx)
99102
int main(int argc, char *argv[])
100103
{
101104
common_setup(argv[0]);
102-
freopen("plugins/askrene/test/data/linear_mcf", "r", stdin);
105+
FILE *f = freopen("plugins/askrene/test/data/linear_mcf", "r", stdin);
106+
CHECK(f);
103107
tal_t *ctx = tal(NULL, tal_t);
104108
CHECK(ctx);
105109

0 commit comments

Comments
 (0)