[Gmp-commit] /var/hg/gmp: Acoid calling mpn_zero_p with zero size.
mercurial at gmplib.org
mercurial at gmplib.org
Sun May 31 04:43:53 UTC 2015
details: /var/hg/gmp/rev/cb5da779cc81
changeset: 16668:cb5da779cc81
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun May 31 06:41:53 2015 +0200
description:
Acoid calling mpn_zero_p with zero size.
diffstat:
mpz/combit.c | 3 ++-
mpz/scan1.c | 2 +-
tests/mpn/t-brootinv.c | 2 +-
tests/mpn/t-div.c | 2 +-
tests/mpn/t-minvert.c | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
diffs (61 lines):
diff -r 00920cc60c42 -r cb5da779cc81 mpz/combit.c
--- a/mpz/combit.c Sat May 30 08:40:19 2015 +0200
+++ b/mpz/combit.c Sun May 31 06:41:53 2015 +0200
@@ -47,7 +47,8 @@
/* Check for the hairy case. d < 0, and we have all zero bits to the
right of the bit to toggle. */
- else if (limb_index < -dsize && mpn_zero_p (dp, limb_index)
+ else if (limb_index < -dsize
+ && (limb_index == 0 || mpn_zero_p (dp, limb_index))
&& (dp[limb_index] & (bit - 1)) == 0)
{
ASSERT (dsize < 0);
diff -r 00920cc60c42 -r cb5da779cc81 mpz/scan1.c
--- a/mpz/scan1.c Sat May 30 08:40:19 2015 +0200
+++ b/mpz/scan1.c Sun May 31 06:41:53 2015 +0200
@@ -90,7 +90,7 @@
{
/* If there's a non-zero limb before ours then we're in the ones
complement region. */
- if (mpn_zero_p (u_ptr, starting_limb)) {
+ if (starting_limb == 0 || mpn_zero_p (u_ptr, starting_limb)) {
if (limb == 0)
/* Seeking for the first non-zero bit, it is the same for u and -u. */
goto search_nonzero;
diff -r 00920cc60c42 -r cb5da779cc81 tests/mpn/t-brootinv.c
--- a/tests/mpn/t-brootinv.c Sat May 30 08:40:19 2015 +0200
+++ b/tests/mpn/t-brootinv.c Sun May 31 06:41:53 2015 +0200
@@ -87,7 +87,7 @@
mpn_powlo (pp, rp, &k, 1, n, scratch);
mpn_mullo_n (app, ap, pp, n);
- if (app[0] != 1 || !mpn_zero_p (app+1, n-1))
+ if (app[0] != 1 || !(n == 1 || mpn_zero_p (app+1, n-1)))
{
gmp_fprintf (stderr,
"mpn_brootinv returned bad result: %u limbs\n",
diff -r 00920cc60c42 -r cb5da779cc81 tests/mpn/t-div.c
--- a/tests/mpn/t-div.c Sat May 30 08:40:19 2015 +0200
+++ b/tests/mpn/t-div.c Sun May 31 06:41:53 2015 +0200
@@ -97,7 +97,7 @@
ASSERT_NOCARRY (refmpn_sub_n (tp, np, tp, nn));
tvalue = "N-Q*D";
- if (!mpn_zero_p (tp + dn, nn - dn) || mpn_cmp (tp, dp, dn) >= 0)
+ if (!(nn == dn || mpn_zero_p (tp + dn, nn - dn)) || mpn_cmp (tp, dp, dn) >= 0)
{
msg = "q too small";
goto error;
diff -r 00920cc60c42 -r cb5da779cc81 tests/mpn/t-minvert.c
--- a/tests/mpn/t-minvert.c Sat May 30 08:40:19 2015 +0200
+++ b/tests/mpn/t-minvert.c Sun May 31 06:41:53 2015 +0200
@@ -43,7 +43,7 @@
return (bn >= 0 && bn <= an
&& mpn_cmp (ap, mpz_limbs_read (b), bn) == 0
- && mpn_zero_p (ap + bn, an - bn));
+ && (an == bn || mpn_zero_p (ap + bn, an - bn)));
}
static mp_bitcnt_t
More information about the gmp-commit
mailing list