git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] resolve-undo.c: silence compiler complaints by casting void * to char *

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Feb 1, 2010, 23:00 UTC
Message-ID
<qzbyPiTgRGI0lsxvEmFa0WtwK5ko5snXQDNffxC66y9v0rlie5pcKzGT28WpzfQlFd0OvJNY_jo@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>

Some compilers produce errors when arithmetic is attempted on pointers to void. We want computations done on byte addresses, so cast them to char * to work them around.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 resolve-undo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/resolve-undo.c b/resolve-undo.c
index 37d73cd..c259fe6 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -75,7 +75,7 @@ struct string_list *resolve_undo_read(void *data, unsigned long size)
 			lost->util = xcalloc(1, sizeof(*ui));
 		ui = lost->util;
 		size -= len;
-		data += len;
+		data = (char*) data + len;
 
 		for (i = 0; i < 3; i++) {
 			ui->mode[i] = strtoul(data, &endptr, 8);
@@ -85,7 +85,7 @@ struct string_list *resolve_undo_read(void *data, unsigned long size)
 			if (size <= len)
 				goto error;
 			size -= len;
-			data += len;
+			data = (char*) data + len;
 		}
 
 		for (i = 0; i < 3; i++) {
@@ -95,7 +95,7 @@ struct string_list *resolve_undo_read(void *data, unsigned long size)
 				goto error;
 			hashcpy(ui->sha1[i], data);
 			size -= 20;
-			data += 20;
+			data = (char*) data + 20;
 		}
 	}
 	return resolve_undo;
-- 
1.6.6
Next: Junio C Hamano
Message 1 of 4 in “resolve-undo.c: silence compiler complaints by casting void * to char *”
  1. resolve-undo.c: silence compiler complaints by casting void * to char *Brandon Casey, Feb 1, 2010
  2. Junio C HamanoFeb 1, 2010
  3. Junio C HamanoFeb 2, 2010
  4. Brandon CaseyFeb 2, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.