git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marco Costalba" <mcostalba@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "Git Mailing List" <git@vger.kernel.org>, "Nicolas Pitre" <nico@cam.org>
Subject: [PATCH] Check for large pack offsets could be optimized away
Date: Thu, 16 Aug 2007 09:58:51 +0200	[thread overview]
Message-ID: <e5bfff550708160058q6674f832m641647cd883accfc@mail.gmail.com> (raw)

Without this fix gcc 4.2.1 warns with:

warning: assuming signed overflow does not occur
when assuming that (X + c) < X is always false

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 sha1_file.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index b219d4d..ba29000 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -524,7 +524,8 @@ static int check_packed_git_idx
 		if (idx_size != min_size) {
 			/* make sure we can deal with large pack offsets */
 			off_t x = 0x7fffffffUL, y = 0xffffffffUL;
-			if (x > (x + 1) || y > (y + 1)) {
+			off_t x1 = x + 1, y1 = y + 1;
+			if (x > x1 || y > y1) {
  				munmap(idx_map, idx_size);
 				return error("pack too large for current definition of off_t in %s", path);
 			}
-- 
1.5.3.rc4.67.gf9286

                 reply	other threads:[~2007-08-16  7:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e5bfff550708160058q6674f832m641647cd883accfc@mail.gmail.com \
    --to=mcostalba@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@cam.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;
as well as URLs for NNTP newsgroup(s).