[Gmp-commit] /var/hg/gmp: mpz_import, mpz_export: Relax ASSERTs and test corn...
mercurial at gmplib.org
mercurial at gmplib.org
Thu Jan 10 13:37:45 CET 2013
details: /var/hg/gmp/rev/f47abbae9591
changeset: 15251:f47abbae9591
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Jan 10 13:37:36 2013 +0100
description:
mpz_import, mpz_export: Relax ASSERTs and test corner conditions.
diffstat:
ChangeLog | 6 ++++++
mini-gmp/mini-gmp.c | 3 +--
mini-gmp/tests/t-import.c | 4 ++--
mpz/export.c | 2 +-
4 files changed, 10 insertions(+), 5 deletions(-)
diffs (59 lines):
diff -r 9a8f6bdcfe67 -r f47abbae9591 ChangeLog
--- a/ChangeLog Thu Jan 10 10:25:14 2013 +0100
+++ b/ChangeLog Thu Jan 10 13:37:36 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mpz/export.c: Less restrictive ASSERTs.
+ * mini-gmp/mini-gmp.c (mpz_export, mpz_import): Likewise.
+ * mini-gmp/tests/t-import.c: Test also size=0 or count=0.
+
2013-01-10 Torbjorn Granlund <tege at gmplib.org>
* mini-gmp/tests/t-import.c (main): Don't drop off functon end.
diff -r 9a8f6bdcfe67 -r f47abbae9591 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Thu Jan 10 10:25:14 2013 +0100
+++ b/mini-gmp/mini-gmp.c Thu Jan 10 13:37:36 2013 +0100
@@ -4032,7 +4032,6 @@
assert (order == 1 || order == -1);
assert (endian >= -1 && endian <= 1);
- assert (size > 0);
if (endian == 0)
endian = gmp_detect_endian ();
@@ -4098,7 +4097,7 @@
assert (order == 1 || order == -1);
assert (endian >= -1 && endian <= 1);
- assert (size > 0);
+ assert (size > 0 || u->_mp_size == 0);
un = GMP_ABS (u->_mp_size);
if (un == 0)
diff -r 9a8f6bdcfe67 -r f47abbae9591 mini-gmp/tests/t-import.c
--- a/mini-gmp/tests/t-import.c Thu Jan 10 10:25:14 2013 +0100
+++ b/mini-gmp/tests/t-import.c Thu Jan 10 13:37:36 2013 +0100
@@ -64,8 +64,8 @@
mpz_init (a);
mpz_init (res);
- for (size = 1; size <= MAX_WORD_SIZE; size++)
- for (count = 1; count <= MAX_WORDS; count++)
+ for (size = 0; size <= MAX_WORD_SIZE; size++)
+ for (count = 0; count <= MAX_WORDS; count++)
for (endian = -1; endian <= 1; endian++)
for (order = -1; order <= 1; order += 2)
{
diff -r 9a8f6bdcfe67 -r f47abbae9591 mpz/export.c
--- a/mpz/export.c Thu Jan 10 10:25:14 2013 +0100
+++ b/mpz/export.c Thu Jan 10 13:37:36 2013 +0100
@@ -47,7 +47,7 @@
ASSERT (order == 1 || order == -1);
ASSERT (endian == 1 || endian == 0 || endian == -1);
ASSERT (nail <= 8*size);
- ASSERT (8*size-nail > 0);
+ ASSERT (nail < 8*size || SIZ(z) == 0); /* nail < 8*size+(SIZ(z)==0) */
if (countp == NULL)
countp = &dummy;
More information about the gmp-commit
mailing list