[PATCH svn-fe] fast-import: make code "-Wpointer-arith" clean
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Feb 28, 2011, 21:32 UTC
- Message-ID
- <20110228213210.GD1942@elie>
- In-Reply-To
- <7vhbbolm5q.fsf@alter.siamese.dyndns.org>
The dereference() function to peel a tree-ish and find the underlying tree expects arithmetic to (void *) to work on byte addresses. We should be reading the text of objects through a char * anyway.
Noticed-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> --- Junio C Hamano wrote:
Show 5 quoted lines
> ... Yikes. I said the above and then my build for "master" breaks with > > fast-import.c: In function 'dereference': > fast-import.c:2885: error: pointer of type 'void *' used in arithmetic > fast-import.c:2890: error: pointer of type 'void *' used in arithmetic
This should fix it, I suppose? A
-std=c99 -O3 -Wall -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-empty-body -Wno-pointer-to-int-cast -Wno-type-limits -Wno-unused-but-set-variable -Wold-style-definition -Wpointer-arith -Wvla -Wdeclaration-after-statement -Werror
build passes, except for an "unsigned long expire" in builtin-reflog that confuses this copy of gcc.
fast-import.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fast-import.c b/fast-import.c index 6c37b84..e1268b8 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2848,7 +2848,7 @@ static struct object_entry *dereference(struct object_entry *oe, unsigned char sha1[20]) { unsigned long size; - void *buf = NULL; + char *buf = NULL; if (!oe) { enum object_type type = sha1_object_info(sha1, NULL); if (type < 0)
-- 1.7.4.1