bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* reallocarray tests: Avoid test failure on NetBSD
@ 2021-05-13 10:17 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2021-05-13 10:17 UTC (permalink / raw)
  To: bug-gnulib

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.  */



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-13 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 10:17 reallocarray tests: Avoid test failure on NetBSD Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).