From: Pierre Habouzit <madcoder@debian.org>
To: git@vger.kernel.org
Cc: Pierre Habouzit <madcoder@debian.org>
Subject: [PATCH] Fix a comparison bug in diff-delta.c
Date: Wed, 23 Aug 2006 04:32:48 +0200 [thread overview]
Message-ID: <1156300368160-git-send-email-madcoder@debian.org> (raw)
(1 << i) < hspace is compared in the `int` space rather that in the unsigned one.
the result will be wrong if hspace is between 0x40000000 and 0x80000000.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
I'm currently trying to make git compile with more strict gcc flags
(-g -O2 -Wall -Wextra -Wno-unused -Werror to be precise) and I've
spotted a first bug due to a signed/unsigned comparison.
If I do understand that bit of code, it should not bite a lot of
people, but this is still a bug ;)
diff-delta.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/diff-delta.c b/diff-delta.c
index 7da9205..a1fadc9 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -152,7 +152,7 @@ struct delta_index * create_delta_index(
initialization in create_delta(). */
entries = (bufsize - 1) / RABIN_WINDOW;
hsize = entries / 4;
- for (i = 4; (1 << i) < hsize && i < 31; i++);
+ for (i = 4; (unsigned)(1 << i) < hsize && i < 31; i++);
hsize = 1 << i;
hmask = hsize - 1;
--
1.4.1.1
next reply other threads:[~2006-08-23 2:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-23 2:32 Pierre Habouzit [this message]
2006-08-23 2:38 ` [PATCH] Fix a comparison bug in diff-delta.c Pierre Habouzit
2006-08-23 3:17 ` Nicolas Pitre
-- strict thread matches above, loose matches on Subject: below --
2006-08-23 9:17 Pierre Habouzit
2006-08-23 13:45 ` Johannes Schindelin
2006-08-23 14:31 ` Pierre Habouzit
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=1156300368160-git-send-email-madcoder@debian.org \
--to=madcoder@debian.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.