[v3,27/29] malloc: Use volatile as compiler barrier in tst-memalign, tst-valloc
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
fail
|
Test failed
|
Commit Message
This is a simpler way to avoid compiler warnings. Apply this to
the pagesize variable as well, to enable future optimizations.
---
malloc/tst-memalign.c | 17 ++++++-----------
malloc/tst-valloc.c | 17 ++++++-----------
2 files changed, 12 insertions(+), 22 deletions(-)
@@ -35,25 +35,20 @@ merror (const char *msg)
static int
do_test (void)
{
+ /* Use volatile for compiler barriers, to avoid
+ Walloc-size-larger-than warnings. */
+ volatile unsigned long int pagesize = getpagesize ();
+ volatile int minus1 = -1;
void *p;
- unsigned long pagesize = getpagesize ();
- unsigned long ptrval;
+ unsigned long int ptrval;
int save;
errno = 0;
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (7, 0)
- /* GCC 7 warns about too-large allocations; here we want to test
- that they fail. */
- DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
-#endif
/* An attempt to allocate a huge value should return NULL and set
errno to ENOMEM. */
- p = memalign (sizeof (void *), -1);
-#if __GNUC_PREREQ (7, 0)
- DIAG_POP_NEEDS_COMMENT;
-#endif
+ p = memalign (sizeof (void *), minus1);
save = errno;
@@ -35,25 +35,20 @@ merror (const char *msg)
static int
do_test (void)
{
+ /* Use volatile for compiler barriers, to avoid
+ Walloc-size-larger-than warnings. */
+ volatile unsigned long int pagesize = getpagesize ();
+ volatile int minus1 = -1;
void *p;
- unsigned long pagesize = getpagesize ();
- unsigned long ptrval;
+ unsigned long int ptrval;
int save;
errno = 0;
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (7, 0)
- /* GCC 7 warns about too-large allocations; here we want to test
- that they fail. */
- DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
-#endif
/* An attempt to allocate a huge value should return NULL and set
errno to ENOMEM. */
- p = valloc (-1);
-#if __GNUC_PREREQ (7, 0)
- DIAG_POP_NEEDS_COMMENT;
-#endif
+ p = valloc (minus1);
save = errno;