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

[PATCH] archive-tar: keep const in checksum calculation

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
May 18, 2012, 05:18 UTC
Message-ID
<4FB5DB93.9000904@lsrfire.ath.cx>
For correctness, don't needlessly drop the const qualifier when casting.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 archive-tar.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/archive-tar.c b/archive-tar.c
index 93387ea..dc91c6b 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -139,13 +139,13 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,
 
 static unsigned int ustar_header_chksum(const struct ustar_header *header)
 {
-	char *p = (char *)header;
+	const char *p = (const char *)header;
 	unsigned int chksum = 0;
 	while (p < header->chksum)
 		chksum += *p++;
 	chksum += sizeof(header->chksum) * ' ';
 	p += sizeof(header->chksum);
-	while (p < (char *)header + sizeof(struct ustar_header))
+	while (p < (const char *)header + sizeof(struct ustar_header))
 		chksum += *p++;
 	return chksum;
 }
-- 
1.7.10.2
Message 1 of 1 in “archive-tar: keep const in checksum calculation”
  1. archive-tar: keep const in checksum calculationRené Scharfe, May 18, 2012

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.