aboutsummaryrefslogtreecommitdiff
path: root/csum-file.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-10-24 04:45:13 -0400
committerJunio C Hamano <gitster@pobox.com>2013-10-24 15:41:56 -0700
commita4165851e769ebc32da48904d58f144f2d93e69a (patch)
treefba46378665b3d9c8d8495920e085a06376e0a3c /csum-file.c
parent7c2b3029df45a74d0ebd11afcc94259791cfb90d (diff)
downloadgit-a4165851e769ebc32da48904d58f144f2d93e69a.tar.gz
git-a4165851e769ebc32da48904d58f144f2d93e69a.tar.xz
silence gcc array-bounds warning
In shorten_unambiguous_ref, we build and cache a reverse-map of the rev-parse rules like this: static char **scanf_fmts; static int nr_rules; if (!nr_rules) { for (; ref_rev_parse_rules[nr_rules]; nr_rules++) ... generate scanf_fmts ... } where ref_rev_parse_rules is terminated with a NULL pointer. Compiling with "gcc -O2 -Wall" does not cause any problems, but compiling with "-O3 -Wall" generates: $ make CFLAGS='-O3 -Wall' refs.o refs.c: In function ‘shorten_unambiguous_ref’: refs.c:3379:29: warning: array subscript is above array bounds [-Warray-bounds] for (; ref_rev_parse_rules[nr_rules]; nr_rules++) Curiously, we can silence this by explicitly nr_rules to 0 in the beginning of the loop, even though the compiler should be able to tell that we follow this code path only when nr_rules is already 0. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.c')
0 files changed, 0 insertions, 0 deletions