Re: [PATCH v2 3/4] bisect--helper: reimplement `bisect_run` shell function in C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 9, 2021, 06:15 UTC
- Message-ID
- <xmqq8s5snfv8.fsf@gitster.g>
- In-Reply-To
- <20210407173334.68222-4-mirucam@gmail.com>
Miriam Rubio <mirucam@gmail.com> writes:
Show 10 quoted lines
> +static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
> +{
> ...
> + while (1) {
> + strvec_clear(&args);
> +
> + printf(_("running %s"), command.buf);
> + res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
> +
> + if (res < 0 && res >= 128) {Sorry for not noticing this total nonsense during my earlier review, but this condition will never trigger.
I would have noticed it if the style consistently used "order quantities from left to right, as if on a number line" convention, i.e.
if (res < 0 && 128 <= res) {Because there are only two valid range notation around a single variable, which are:
(res < 0 || 128 <= res) - meaning 'res' is outside a span, or
(0 <= res && res < 128) - meaning 'res' is inside a span.and the above rewriten form is neither, it would have stood out as an error immediately.