public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Kyle McMartin <kyle@mcmartin.ca>, Helge Deller <deller@gmx.de>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	linux-parisc@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] parisc: test off by one in sgl_frem() and dbl_frem()
Date: Sun, 27 Dec 2009 14:21:44 +0100	[thread overview]
Message-ID: <4B375F68.80301@gmail.com> (raw)

With `while (stepcount-- > 0)' stepcount reaches -1 after the loop.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 arch/parisc/math-emu/dfrem.c |    2 +-
 arch/parisc/math-emu/sfrem.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Unless I am missing something?

diff --git a/arch/parisc/math-emu/dfrem.c b/arch/parisc/math-emu/dfrem.c
index b983785..3283445 100644
--- a/arch/parisc/math-emu/dfrem.c
+++ b/arch/parisc/math-emu/dfrem.c
@@ -234,7 +234,7 @@ dbl_frem (dbl_floating_point * srcptr1, dbl_floating_point * srcptr2,
 		Dbl_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2,opnd1p1,opnd1p2);
 		roundup = TRUE;
 	}
-	if (stepcount > 0 || Dbl_iszero(opnd1p1,opnd1p2)) {
+	if (stepcount >= 0 || Dbl_iszero(opnd1p1,opnd1p2)) {
 		/* division is exact, remainder is zero */
 		Dbl_setzero_exponentmantissa(resultp1,resultp2);
 		Dbl_copytoptr(resultp1,resultp2,dstptr);
diff --git a/arch/parisc/math-emu/sfrem.c b/arch/parisc/math-emu/sfrem.c
index 3a1b7a3..ad87832 100644
--- a/arch/parisc/math-emu/sfrem.c
+++ b/arch/parisc/math-emu/sfrem.c
@@ -229,7 +229,7 @@ sgl_frem (sgl_floating_point * srcptr1, sgl_floating_point * srcptr2,
 		Sgl_subtract(opnd1,opnd2,opnd1);
 		roundup = TRUE;
 	}
-	if (stepcount > 0 || Sgl_iszero(opnd1)) {
+	if (stepcount >= 0 || Sgl_iszero(opnd1)) {
 		/* division is exact, remainder is zero */
 		Sgl_setzero_exponentmantissa(result);
 		*dstptr = result;

             reply	other threads:[~2009-12-27 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-27 13:21 Roel Kluin [this message]
2009-12-27 15:10 ` [PATCH] parisc: test off by one in sgl_frem() and dbl_frem() John David Anglin
2009-12-27 15:30 ` James Bottomley
2009-12-27 21:11   ` Roel Kluin

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=4B375F68.80301@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=deller@gmx.de \
    --cc=jejb@parisc-linux.org \
    --cc=kyle@mcmartin.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.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