diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-07-12 14:12:27 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-07-12 14:12:27 -0400 |
commit | 663a2b938707458de4e87be68cffb6a970e771c6 (patch) | |
tree | f1131827ecc234f6b4eb22387220836c68f3010d | |
parent | afdc5dca7ca378cb75fe2a2c9df3881a89ba17dd (diff) | |
download | bfs-663a2b938707458de4e87be68cffb6a970e771c6.tar.xz |
parse: Reject -j0
-rw-r--r-- | src/parse.c | 10 | ||||
-rw-r--r-- | tests/bfs/j0.sh | 1 |
2 files changed, 10 insertions, 1 deletions
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 |