From: Junio C Hamano <junkio@cox.net>
To: Nicolas Pitre <nico@cam.org>
Cc: Linus Torvalds <torvalds@osdl.org>, git@vger.kernel.org
Subject: [PATCH] Fixlets on top of Nico's clean-up.
Date: Wed, 29 Jun 2005 00:32:11 -0700 [thread overview]
Message-ID: <7vpsu5ehz8.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.63.0506290246130.1667@localhost.localdomain> (Nicolas Pitre's message of "Wed, 29 Jun 2005 02:49:56 -0400 (EDT)")
Do we care about a corner case where delta_size is not smaller
than 4 bytes, *datap passed to get_delta_hdr_size() points at
some bytes before a mmaped page boundary, and all the bytes til
the end of that page have high-bit set? The said inline
function would step over the page boundary and would presumably
segfault/sigbus.
Other than that, with the attached patch on top of it, I find
your clean-up very pleasant to read. Please consider it acked.
------------
If we prefer 0 as maxsize for diff_delta() to say "unlimited",
let's be consistent about it.
This patch also fixes type mismatch in a call to get_delta_hdr_size()
from packed_delta_info().
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diffcore-break.c | 2 +-
sha1_file.c | 11 ++++-------
test-delta.c | 2 +-
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/diffcore-break.c b/diffcore-break.c
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -65,7 +65,7 @@ static int should_break(struct diff_file
delta = diff_delta(src->data, src->size,
dst->data, dst->size,
- &delta_size, ~0UL);
+ &delta_size, 0);
/* Estimate the edit size by interpreting delta. */
if (count_delta(delta, delta_size,
diff --git a/sha1_file.c b/sha1_file.c
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -598,9 +598,9 @@ static int packed_delta_info(unsigned ch
char *type,
unsigned long *sizep)
{
- unsigned char *data;
+ const unsigned char *data;
unsigned char delta_head[64];
- unsigned long data_size, result_size, base_size, verify_base_size;
+ unsigned long result_size, base_size, verify_base_size;
z_stream stream;
int st;
@@ -609,13 +609,10 @@ static int packed_delta_info(unsigned ch
if (sha1_object_info(base_sha1, type, &base_size))
die("cannot get info for delta-pack base");
- data = base_sha1 + 20;
- data_size = left - 20;
-
memset(&stream, 0, sizeof(stream));
- stream.next_in = data;
- stream.avail_in = data_size;
+ data = stream.next_in = base_sha1 + 20;
+ stream.avail_in = left - 20;
stream.next_out = delta_head;
stream.avail_out = sizeof(delta_head);
diff --git a/test-delta.c b/test-delta.c
--- a/test-delta.c
+++ b/test-delta.c
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
if (argv[1][1] == 'd')
out_buf = diff_delta(from_buf, from_size,
data_buf, data_size,
- &out_size, ~0UL);
+ &out_size, 0);
else
out_buf = patch_delta(from_buf, from_size,
data_buf, data_size,
------------------------------------------------
prev parent reply other threads:[~2005-06-29 7:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-29 6:49 [PATCH] assorted delta code cleanup Nicolas Pitre
2005-06-29 7:10 ` Matthias Urlichs
2005-06-29 7:32 ` Junio C Hamano [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vpsu5ehz8.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=nico@cam.org \
--cc=torvalds@osdl.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox