{"thread":{"id":"5362","subject":"[PATCH] Fix a comparison bug in diff-delta.c","startedAt":"2006-08-23T09:17:55Z","lastAt":"2006-08-23T14:31:10Z","messageCount":3,"participants":["Pierre Habouzit","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25794","messageId":"1156324675415-git-send-email-madcoder@debian.org","threadId":"5362","inReplyTo":null,"subject":"[PATCH] Fix a comparison bug in diff-delta.c","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2006-08-23T09:17:55Z","receivedAt":"2006-08-23T09:17:55Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"  (1 << i) < hspace is compared in the `int` space rather that in the\n  unsigned one.  the result will be wrong if hspace is between 0x40000000\n  and 0x80000000.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n\n  This is a replacement for <1156300368160-git-send-email-madcoder@debian.org>\n  avoiding the ugly cast, and using 1u instead.\n\n diff-delta.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 7da9205..51e2e56 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -152,7 +152,7 @@ struct delta_index * create_delta_index(\n \t   initialization in create_delta(). */\n \tentries = (bufsize - 1)  / RABIN_WINDOW;\n \thsize = entries / 4;\n-\tfor (i = 4; (1 << i) < hsize && i < 31; i++);\n+\tfor (i = 4; (1u << i) < hsize && i < 31; i++);\n \thsize = 1 << i;\n \thmask = hsize - 1;\n \n-- \n1.4.1.1\n"},{"id":"25807","messageId":"Pine.LNX.4.63.0608231542380.28360@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5362","inReplyTo":"1156324675415-git-send-email-madcoder@debian.org","subject":"Re: [PATCH] Fix a comparison bug in diff-delta.c","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-08-23T13:45:04Z","receivedAt":"2006-08-23T13:45:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Aug 2006, Pierre Habouzit wrote:\n\n> -\tfor (i = 4; (1 << i) < hsize && i < 31; i++);\n> +\tfor (i = 4; (1u << i) < hsize && i < 31; i++);\n\nThe variable i never takes on the value 31 (or any higher value), so there \nis no bug here. Unless you port git to a system where an int has less than \n32 bit.\n\nCiao,\nDscho\n"},{"id":"25808","messageId":"200608231631.12958.madcoder@debian.org","threadId":"5362","inReplyTo":"Pine.LNX.4.63.0608231542380.28360@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Fix a comparison bug in diff-delta.c","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2006-08-23T14:31:10Z","receivedAt":"2006-08-23T14:31:10Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Le mer 23 août 2006 15:45, Johannes Schindelin a écrit :\n> Hi,\n>\n> On Wed, 23 Aug 2006, Pierre Habouzit wrote:\n> > -\tfor (i = 4; (1 << i) < hsize && i < 31; i++);\n> > +\tfor (i = 4; (1u << i) < hsize && i < 31; i++);\n>\n> The variable i never takes on the value 31 (or any higher value), so\n> there is no bug here. Unless you port git to a system where an int\n> has less than 32 bit.\n\nthat remains quite tasteless though, and maybe that patch can be \nintegrated to the \"cleanup\" series I sent later today.\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"}]}