From: Jonathan Nieder <jrnieder@gmail.com>
To: John Keeping <john@keeping.me.uk>
Cc: git@vger.kernel.org, Antoine Pelisse <apelisse@gmail.com>
Subject: Re: [PATCH 1/3] fix clang -Wtautological-compare with unsigned enum
Date: Sun, 3 Feb 2013 11:38:28 -0800 [thread overview]
Message-ID: <20130203193816.GA3221@elie.Belkin> (raw)
In-Reply-To: <a9fe675ed9b34d3c15f4678ee13e90cddaa36055.1359901732.git.john@keeping.me.uk>
John Keeping wrote:
> From: Antoine Pelisse <apelisse@gmail.com>
>
> 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.
next prev parent reply other threads:[~2013-02-03 19:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-03 14:37 [PATCH 0/3] Make Git compile warning-free with Clang John Keeping
2013-02-03 14:37 ` [PATCH 1/3] fix clang -Wtautological-compare with unsigned enum John Keeping
2013-02-03 19:38 ` Jonathan Nieder [this message]
2013-02-03 14:37 ` [PATCH 2/3] combine-diff: suppress a clang warning John Keeping
2013-02-03 18:20 ` Tay Ray Chuan
2013-02-03 19:06 ` John Keeping
2013-02-03 19:58 ` Junio C Hamano
2013-02-03 20:31 ` John Keeping
2013-02-03 21:07 ` Junio C Hamano
2013-02-03 23:15 ` John Keeping
2013-02-04 0:24 ` Junio C Hamano
2013-02-05 20:25 ` [PATCH] t4038: add tests for "diff --cc --raw <trees>" John Keeping
2013-02-05 20:48 ` Junio C Hamano
2013-02-05 21:39 ` [PATCH v2] " John Keeping
2013-02-05 22:27 ` Junio C Hamano
2013-02-07 4:12 ` [PATCH 2/3] combine-diff: suppress a clang warning Miles Bader
2013-02-07 8:41 ` John Keeping
2013-02-03 14:37 ` [PATCH 3/3] builtin/apply: tighten (dis)similarity index parsing John Keeping
2013-02-03 20:50 ` Junio C Hamano
2013-02-03 17:13 ` [PATCH 0/3] Make Git compile warning-free with Clang Antoine Pelisse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130203193816.GA3221@elie.Belkin \
--to=jrnieder@gmail.com \
--cc=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).