bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reallocarray tests: Avoid test failure on NetBSD


From: Bruno Haible
Subject: reallocarray tests: Avoid test failure on NetBSD
Date: Thu, 13 May 2021 12:17:40 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; )

On NetBSD 8 and 9, in 64-bit mode, I see a test failure:
test-reallocarray fails with exit code 4.

The cause is that when n*s overflows, reallocarray(p,n,s) fails with
errno = EOVERFLOW — unlike other implementations that fail with errno = ENOMEM.
But EOVERFLOW is just as reasonable (even more reasonable, IMO) than ENOMEM
in this case. So, let's allow it, and make the test succeed without
overriding reallocarray().


2021-05-13  Bruno Haible  <bruno@clisp.org>

        reallocarray tests: Avoid test failure on NetBSD.
        * tests/test-reallocarray.c (main): Accept EOVERFLOW error code.

diff --git a/tests/test-reallocarray.c b/tests/test-reallocarray.c
index 6de355e..8067542 100644
--- a/tests/test-reallocarray.c
+++ b/tests/test-reallocarray.c
@@ -41,7 +41,8 @@ main ()
       p = reallocarray (p, SIZE_MAX / n + 1, n);
       if (p)
         return 3;
-      if (errno != ENOMEM)
+      if (!(errno == ENOMEM
+            || errno == EOVERFLOW /* NetBSD */))
         return 4;
 
       /* Reallocarray should not crash with zero sizes.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]