Re: [PATCH 3/3] grep: get rid of useless x < 0 comparison on an enum member
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 7, 2011, 21:18 UTC
- Message-ID
- <7vlirr1vi5.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20111107194912.GA12469@elie.hsd1.il.comcast.net>
Jonathan Nieder <jrnieder@gmail.com> writes:
> [jn: drop the GREP_HEADER_FIELD_MAX <= p->field check, too, > for symmetry]
Umm, why is this removal of defensive programming practice an improvement? This part is mostly my code and because I know what I wrote is almost always perfect, so I do not think there is any real harm done, but still...
Show 19 quoted lines
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> grep.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index b29d09c7..424c46cd 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -327,8 +327,6 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt)
> for (p = opt->header_list; p; p = p->next) {
> if (p->token != GREP_PATTERN_HEAD)
> die("bug: a non-header pattern in grep header list.");
> - if (p->field < 0 || GREP_HEADER_FIELD_MAX <= p->field)
> - die("bug: unknown header field %d", p->field);
> compile_regexp(p, opt);
> }