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>

Antoine Pelisse committed Feb 3, 2013 at 14:37 UTC 3ce3ffb840a1dfa7fcbafa9309fab37478605d08
2 files changed +4 -2
grep.c
+2 -1
@@ -625,7 +625,8 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt)
625 for (p = opt->header_list; p; p = p->next) {
626 if (p->token != GREP_PATTERN_HEAD)
627 die("bug: a non-header pattern in grep header list.");
628 - if (p->field < 0 || GREP_HEADER_FIELD_MAX <= p->field)
628 + if (p->field < GREP_HEADER_FIELD_MIN ||
629 + GREP_HEADER_FIELD_MAX <= p->field)
630 die("bug: unknown header field %d", p->field);
631 compile_regexp(p, opt);
632 }
grep.h
+2 -1
@@ -28,7 +28,8 @@ enum grep_context {
28 };
29
30 enum grep_header_field {
31 - GREP_HEADER_AUTHOR = 0,
31 + GREP_HEADER_FIELD_MIN = 0,
32 + GREP_HEADER_AUTHOR = GREP_HEADER_FIELD_MIN,
33 GREP_HEADER_COMMITTER,
34 GREP_HEADER_REFLOG,
35