From: "Shawn O. Pearce" <spearce@spearce.org>
To: "Sohn, Matthias" <matthias.sohn@sap.com>
Cc: Robin Rosenberg <robin.rosenberg@dewire.com>, git@vger.kernel.org
Subject: Re: [PATCH JGIT] Computation of average could overflow
Date: Mon, 27 Apr 2009 16:17:57 -0700 [thread overview]
Message-ID: <20090427231757.GM23604@spearce.org> (raw)
In-Reply-To: <366BBB1215D0AB4B8A153AF047A2878002FCE7E7@dewdfe18.wdf.sap.corp>
"Sohn, Matthias" <matthias.sohn@sap.com> wrote:
> The code computes the average of two integers using either division or
> signed right shift, and then uses the result as the
> index of an array. If the values being averaged are very large, this can
> overflow (resulting in the computation of a negative
> average). Assuming that the result is intended to be nonnegative, you
> can use an unsigned right shift instead. In other
> words, rather that using (low+high)/2, use (low+high) >>> 1
Thanks, applied. But your patch was line wrapped. I had to unwrap
it by hand. Please try to configure your MUA not to line wrap
patches when it sends them. :-|
> .../src/org/spearce/jgit/dircache/DirCache.java | 2 +-
> .../src/org/spearce/jgit/lib/Tree.java | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
--
Shawn.
prev parent reply other threads:[~2009-04-27 23:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-27 23:02 [PATCH JGIT] Computation of average could overflow Sohn, Matthias
2009-04-27 23:05 ` [PATCH JGIT] Method invokes inefficient new String(String) constructor Sohn, Matthias
2009-04-27 23:08 ` [PATCH JGIT] Method invokes inefficient Number constructor; use static valueOf instead Sohn, Matthias
2009-04-27 23:10 ` [PATCH JGIT] Method ignores results of InputStream.skip() Sohn, Matthias
2009-04-27 23:21 ` Shawn O. Pearce
2009-04-28 22:26 ` Sohn, Matthias
2009-04-27 23:15 ` [PATCH JGIT] Method invokes inefficient Number constructor; use static valueOf instead Shawn O. Pearce
2009-04-27 23:17 ` [PATCH JGIT] Method invokes inefficient new String(String) constructor Shawn O. Pearce
2009-04-27 23:17 ` Shawn O. Pearce [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=20090427231757.GM23604@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=matthias.sohn@sap.com \
--cc=robin.rosenberg@dewire.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 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.