From: John Keeping <john@keeping.me.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] bisect: avoid signed integer overflow
Date: Wed, 3 Apr 2013 20:17:55 +0100 [thread overview]
Message-ID: <20130403191755.GI2222@serenity.lan> (raw)
In-Reply-To: <7vzjxgabd6.fsf@alter.siamese.dyndns.org>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
Changes since v1:
- Change the function signature instead of casting a value in the
function.
- This lets us remove an existing cast.
bisect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bisect.c b/bisect.c
index bd1b7b5..374d9e2 100644
--- a/bisect.c
+++ b/bisect.c
@@ -525,9 +525,9 @@ struct commit_list *filter_skipped(struct commit_list *list,
* is increased by one between each call, but that should not matter
* for this application.
*/
-static int get_prn(int count) {
+static unsigned get_prn(unsigned count) {
count = count * 1103515245 + 12345;
- return ((unsigned)(count/65536) % PRN_MODULO);
+ return (count/65536) % PRN_MODULO;
}
/*
--
1.8.2.540.gf023cfe
prev parent reply other threads:[~2013-04-03 19:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 19:50 [PATCH 0/2] Fixes for undefined behaviour John Keeping
2013-04-02 19:50 ` [PATCH 1/2] diffcore-break: don't divide by zero John Keeping
2013-04-02 21:15 ` Junio C Hamano
2013-04-02 21:36 ` John Keeping
2013-04-02 22:41 ` Junio C Hamano
2013-04-03 19:24 ` [PATCH v2] " John Keeping
2013-04-02 19:50 ` [PATCH 2/2] bisect: avoid signed integer overflow John Keeping
2013-04-02 21:09 ` Junio C Hamano
2013-04-03 19:17 ` John Keeping [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=20130403191755.GI2222@serenity.lan \
--to=john@keeping.me.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).