git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Alfred M. Szmidt" <ams@gnu.org>
To: git@vger.kernel.org
Subject: [PATCH] Cast things properly to handle >2G files.
Date: Sun, 14 Jun 2009 16:03:03 -0400	[thread overview]
Message-ID: <E1MFvux-0001ix-I7@fencepost.gnu.org> (raw)

This small patch fixes things so that repack, fsck, and other things
work on >2GiB files.  There are still some other problems (cloning
over ssh being one), but this makes it atleast possible to handle such
files.

(not subscribed, please CC)

---
 delta.h       |    2 +-
 patch-delta.c |    2 +-
 sha1_file.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/delta.h b/delta.h
index 40ccf5a..b3acc72 100644
--- a/delta.h
+++ b/delta.h
@@ -95,7 +95,7 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
 	int i = 0;
 	do {
 		cmd = *data++;
-		size |= (cmd & ~0x80) << i;
+		size |= (cmd & ~0x80UL) << i;
 		i += 7;
 	} while (cmd & 0x80 && data < top);
 	*datap = data;
diff --git a/patch-delta.c b/patch-delta.c
index ed9db81..a9ad2bc 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -44,7 +44,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
 			if (cmd & 0x01) cp_off = *data++;
 			if (cmd & 0x02) cp_off |= (*data++ << 8);
 			if (cmd & 0x04) cp_off |= (*data++ << 16);
-			if (cmd & 0x08) cp_off |= (*data++ << 24);
+			if (cmd & 0x08) cp_off |= ((unsigned long) *data++ << 24);
 			if (cmd & 0x10) cp_size = *data++;
 			if (cmd & 0x20) cp_size |= (*data++ << 8);
 			if (cmd & 0x40) cp_size |= (*data++ << 16);
diff --git a/sha1_file.c b/sha1_file.c
index e73cd4f..4566ea1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1176,7 +1176,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
 			return 0;
 		}
 		c = buf[used++];
-		size += (c & 0x7f) << shift;
+		size += (c & 0x7fUL) << shift;
 		shift += 7;
 	}
 	*sizep = size;
-- 
1.6.3.2.225.gb8364.dirty

             reply	other threads:[~2009-06-14 20:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 20:03 Alfred M. Szmidt [this message]
2009-06-14 20:17 ` [PATCH] Cast things properly to handle >2G files Johannes Schindelin
2009-06-15  2:43   ` Nicolas Pitre
2009-06-15  3:39   ` Alfred M. Szmidt
2009-06-15  4:06     ` Junio C Hamano
2009-06-15  8:45       ` Johannes Schindelin
2009-06-15  4:25     ` Linus Torvalds
2009-06-17 22:27       ` Alfred M. Szmidt
2009-06-17 22:48         ` Linus Torvalds
2009-06-17 22:27       ` Alfred M. Szmidt
2009-06-17 22:45         ` Linus Torvalds
2009-06-17 23:16           ` Junio C Hamano
2009-06-18  0:22           ` Fix big left-shifts of unsigned char Linus Torvalds
2009-06-18  8:12             ` Johannes Schindelin
2009-06-18  8:21               ` Junio C Hamano
2009-06-18 16:08               ` Linus Torvalds
2009-06-18 16:45                 ` Johannes Schindelin
2009-06-18 17:15                   ` Linus Torvalds
2009-06-18 17:28                     ` Fix various sparse warnings in the git source code Linus Torvalds
2009-06-18 17:45                       ` Matthieu Moy
2009-06-18 17:52                         ` Linus Torvalds
2009-06-18 21:48                       ` Linus Torvalds
2009-06-17 22:51         ` [PATCH] Cast things properly to handle >2G files Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1MFvux-0001ix-I7@fencepost.gnu.org \
    --to=ams@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).