summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-07-12 14:12:27 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-07-12 14:12:27 -0400
commit663a2b938707458de4e87be68cffb6a970e771c6 (patch)
treef1131827ecc234f6b4eb22387220836c68f3010d /src
parentafdc5dca7ca378cb75fe2a2c9df3881a89ba17dd (diff)
downloadbfs-663a2b938707458de4e87be68cffb6a970e771c6.tar.xz
parse: Reject -j0
Diffstat (limited to 'src')
-rw-r--r--src/parse.c10
1 files changed, 9 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;
}