git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Check for large pack offsets could be optimized away

From
MCMarco Costalba <mcostalba@gmail.com>
Date
Aug 16, 2007, 07:58 UTC
Message-ID
<e5bfff550708160058q6674f832m641647cd883accfc@mail.gmail.com>
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
Message 1 of 1 in “Check for large pack offsets could be optimized away”
  1. Check for large pack offsets could be optimized awayMarco Costalba, Aug 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.