Skip to contentSkip to conversation

archive-tar: keep const in checksum calculation

PATCH New René Scharfe 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 archive-tar: keep const in checksum calculation

For correctness, don't needlessly drop the const qualifier when casting.

---
 archive-tar.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
archive-tar.c +2 -2
index 93387ea..dc91c6b 100644
@@ -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;
 }
Signature · 1 line
1.7.10.2