* tests/test-malloc-gnu.c: Include <errno.h>.
(main): Verify that, when an allocation larger than PTRDIFF_MAX failed,
errno is ENOMEM.
* tests/test-realloc-gnu.c: Likewise.
* tests/test-calloc-gnu.c: Likewise.
+2021-05-09 Bruno Haible <bruno@clisp.org>
+
+ malloc-gnu, realloc-gnu, calloc-gnu tests: Verify errno is set.
+ * tests/test-malloc-gnu.c: Include <errno.h>.
+ (main): Verify that, when an allocation larger than PTRDIFF_MAX failed,
+ errno is ENOMEM.
+ * tests/test-realloc-gnu.c: Likewise.
+ * tests/test-calloc-gnu.c: Likewise.
+
2021-05-09 Bruno Haible <bruno@clisp.org>
getrandom: Fail with ENOSYS when the system has no randomness source.
#include <config.h>
#include <stdlib.h>
+
+#include <errno.h>
#include <stdint.h>
/* Return N.
for (size_t n = 2; n != 0; n <<= 1)
{
void *volatile p = calloc (PTRDIFF_MAX / n + 1, identity (n));
- if (p != NULL)
+ if (!(p == NULL && errno == ENOMEM))
return 2;
p = calloc (SIZE_MAX / n + 1, identity (n));
- if (p != NULL)
+ if (!(p == NULL && errno == ENOMEM))
return 3;
}
}
#include <config.h>
#include <stdlib.h>
+
+#include <errno.h>
#include <stdint.h>
int
{
size_t one = argc != 12345;
p = malloc (PTRDIFF_MAX + one);
- if (p != NULL)
+ if (!(p == NULL && errno == ENOMEM))
return 1;
}
#include <config.h>
#include <stdlib.h>
+
+#include <errno.h>
#include <stdint.h>
int
{
size_t one = argc != 12345;
p = realloc (p, PTRDIFF_MAX + one);
- if (p != NULL)
+ if (!(p == NULL && errno == ENOMEM))
return 1;
}