Thread (27 messages) flat view 27 messages, 7 authors, 2016-08-13
STALE3691d

[PATCH] diff.c: fix pointer type warning

From: René Scharfe <hidden>
Date: 2016-06-15 22:45:48
Subsystem: the rest · Maintainer: Linus Torvalds

As Mark Burton noted, the conversion to strbuf_readlink() caused a
compile warning on some architectures:
diff.c: In function ‘diff_populate_filespec’:
diff.c:1781: warning: passing argument 2 of ‘strbuf_detach’ from incompatible pointer type
A pointer to an unsigned long is given while a pointer to a size_t is
expected; the two types are not considered to be equivalent everywhere.

The real fix would be to change the type of the size member of struct
diff_filespec to size_t, but that would cause other warnings in
connection with functions expecting unsigned long, and attempts to fix
them might loose an avalanche of changes.  Later.  This patch just
silences the warning by adding an (implicit) casting step.

Reported-by: Mark Burton <redacted>
Signed-off-by: Rene Scharfe <redacted>
---
 diff.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index f160c1a..0484601 100644
--- a/diff.c
+++ b/diff.c
@@ -1778,7 +1778,8 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
 
 			if (strbuf_readlink(&sb, s->path, s->size))
 				goto err_empty;
-			s->data = strbuf_detach(&sb, &s->size);
+			s->size = sb.len;
+			s->data = strbuf_detach(&sb, NULL);
 			s->should_free = 1;
 			return 0;
 		}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help