Thread (5 messages) 5 messages, 3 authors, 2016-06-15

[PATCH svn-fe] fast-import: make code "-Wpointer-arith" clean

flat view
DORMANTno replies

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:50:41
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

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 [off-list ref]
Signed-off-by: Jonathan Nieder <redacted>
---
Junio C Hamano wrote:
... 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help