* [PATCH] parisc: test off by one in sgl_frem() and dbl_frem()
@ 2009-12-27 13:21 Roel Kluin
2009-12-27 15:10 ` John David Anglin
2009-12-27 15:30 ` James Bottomley
0 siblings, 2 replies; 4+ messages in thread
From: Roel Kluin @ 2009-12-27 13:21 UTC (permalink / raw)
To: Kyle McMartin, Helge Deller, James E.J. Bottomley, linux-parisc,
Andrew Morton, LKML
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;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] parisc: test off by one in sgl_frem() and dbl_frem()
2009-12-27 13:21 [PATCH] parisc: test off by one in sgl_frem() and dbl_frem() Roel Kluin
@ 2009-12-27 15:10 ` John David Anglin
2009-12-27 15:30 ` James Bottomley
1 sibling, 0 replies; 4+ messages in thread
From: John David Anglin @ 2009-12-27 15:10 UTC (permalink / raw)
To: Roel Kluin; +Cc: kyle, deller, jejb, linux-parisc, akpm, linux-kernel
> 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?
Are you sure the correct fix isn't to move the decrement of stepcount
into the loop?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] parisc: test off by one in sgl_frem() and dbl_frem()
2009-12-27 13:21 [PATCH] parisc: test off by one in sgl_frem() and dbl_frem() Roel Kluin
2009-12-27 15:10 ` John David Anglin
@ 2009-12-27 15:30 ` James Bottomley
2009-12-27 21:11 ` Roel Kluin
1 sibling, 1 reply; 4+ messages in thread
From: James Bottomley @ 2009-12-27 15:30 UTC (permalink / raw)
To: Roel Kluin
Cc: Kyle McMartin, Helge Deller, James E.J. Bottomley, linux-parisc,
Andrew Morton, LKML
On Sun, 2009-12-27 at 14:21 +0100, Roel Kluin wrote:
> With `while (stepcount-- > 0)' stepcount reaches -1 after the loop.
This is true, but seems to be by design
> 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;
Your patch does nothing to the actual execution flow (Sgl_iszero is true
if stepcount == 0) ... what's the point of applying it?
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] parisc: test off by one in sgl_frem() and dbl_frem()
2009-12-27 15:30 ` James Bottomley
@ 2009-12-27 21:11 ` Roel Kluin
0 siblings, 0 replies; 4+ messages in thread
From: Roel Kluin @ 2009-12-27 21:11 UTC (permalink / raw)
To: James Bottomley
Cc: Kyle McMartin, Helge Deller, James E.J. Bottomley,
John David Anglin, linux-parisc, Andrew Morton, LKML
Op 27-12-09 16:30, James Bottomley schreef:
> On Sun, 2009-12-27 at 14:21 +0100, Roel Kluin wrote:
>> With `while (stepcount-- > 0)' stepcount reaches -1 after the loop.
>
> This is true, but seems to be by design
>> - if (stepcount > 0 || Sgl_iszero(opnd1)) {
>> + if (stepcount >= 0 || Sgl_iszero(opnd1)) {
>
> Your patch does nothing to the actual execution flow (Sgl_iszero is true
> if stepcount == 0) ... what's the point of applying it?
>
> James
Ok, please ignore and thanks (also to Dave) for review.
Roel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-27 21:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-27 13:21 [PATCH] parisc: test off by one in sgl_frem() and dbl_frem() Roel Kluin
2009-12-27 15:10 ` John David Anglin
2009-12-27 15:30 ` James Bottomley
2009-12-27 21:11 ` Roel Kluin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox