From: Jonathan Nieder Date: Sun, 03 Feb 2013 19:38:28 GMT Subject: Re: [PATCH 1/3] fix clang -Wtautological-compare with unsigned enum Message-ID: <20130203193816.GA3221@elie.Belkin> In-Reply-To: John Keeping wrote: > From: Antoine Pelisse > > Create a GREP_HEADER_FIELD_MIN so we can check that the field value is > sane and silent the clang warning. Thanks. Looks good to me. [...] > --- a/grep.c > +++ b/grep.c > @@ -625,7 +625,8 @@ 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) > + if (p->field < GREP_HEADER_FIELD_MIN || > + GREP_HEADER_FIELD_MAX <= p->field) > die("bug: unknown header field %d", p->field); I also think it would be fine to drop this test or replace it with an assert((unsigned) p->field < ARRAY_SIZE(header_field)); because we know the test never trips.