Commit b42a7f01a5114bd0e92d1e3c7c37ffbd4f8702ff

Kirill A. Shutemov 2011-07-15T15:07:59

reflog: fix cast warning /home/kas/git/public/libgit2/src/reflog.c: In function ‘reflog_parse’: /home/kas/git/public/libgit2/src/reflog.c:148:17: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/reflog.c b/src/reflog.c
index da61fd7..c90abb2 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -145,12 +145,12 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
 		if (*buf == '\t') {
 			/* We got a message. Read everything till we reach LF. */
 			seek_forward(1);
-			entry->msg = (char *)buf;
+			ptr = buf;
 
 			while (*buf && *buf != '\n')
 				seek_forward(1);
 
-			entry->msg = git__strndup(entry->msg, buf - entry->msg);
+			entry->msg = git__strndup(ptr, buf - ptr);
 		} else
 			entry->msg = NULL;