From 663a2b938707458de4e87be68cffb6a970e771c6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 12 Jul 2023 14:12:27 -0400 Subject: parse: Reject -j0 --- src/parse.c | 10 +++++++++- tests/bfs/j0.sh | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/bfs/j0.sh diff --git a/src/parse.c b/src/parse.c index c225a5b..6b1eaa0 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1623,11 +1623,19 @@ static struct bfs_expr *parse_jobs(struct parser_state *state, int arg1, int arg return NULL; } - if (!parse_int(state, expr->argv, expr->argv[0] + 2, &state->ctx->threads, IF_INT | IF_UNSIGNED)) { + unsigned int n; + if (!parse_int(state, expr->argv, expr->argv[0] + 2, &n, IF_INT | IF_UNSIGNED)) { bfs_expr_free(expr); return NULL; } + if (n == 0) { + parse_expr_error(state, expr, "${bld}0${rs} is not enough threads.\n"); + bfs_expr_free(expr); + return NULL; + } + + state->ctx->threads = n; return expr; } diff --git a/tests/bfs/j0.sh b/tests/bfs/j0.sh new file mode 100644 index 0000000..97a7c5c --- /dev/null +++ b/tests/bfs/j0.sh @@ -0,0 +1 @@ +! invoke_bfs -j0 basic -- cgit v1.2.3