summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorAntoine Pelisse <apelisse@gmail.com>2013-02-03 14:37:09 +0000
committerJunio C Hamano <gitster@pobox.com>2013-02-25 07:35:55 -0800
commit3ce3ffb840a1dfa7fcbafa9309fab37478605d08 (patch)
tree559c88acc087efae95e25a70067ff5e1afa0b49c /grep.c
parent5ded807f7c0be10ecbb31555e5d10dee553752d6 (diff)
downloadgit-3ce3ffb840a1dfa7fcbafa9309fab37478605d08.tar.gz
fix clang -Wtautological-compare with unsigned enum
Create a GREP_HEADER_FIELD_MIN so we can check that the field value is sane and silence the clang warning. Clang warning happens because the enum is unsigned (this is implementation-defined, and there is no negative fields) and the check is then tautological. Signed-off-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: John Keeping <john@keeping.me.uk> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/grep.c b/grep.c
index 4bd1b8b1dd..bb548cae69 100644
--- 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);
compile_regexp(p, opt);
}