about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
authorStan Shebs <stanshebs@google.com>2018-05-09 11:28:09 -0700
committerStan Shebs <stanshebs@google.com>2018-05-09 11:28:09 -0700
commit58f9551f5bac093dac2dcf3c66e32a4934ff8bd6 (patch)
tree3382074bd74f305347d495406e221aa2936ba388 /malloc
parent40513af8adceabbfbfd7c64631c0fb6e57373c23 (diff)
downloadglibc-58f9551f5bac093dac2dcf3c66e32a4934ff8bd6.tar.gz
glibc-58f9551f5bac093dac2dcf3c66e32a4934ff8bd6.tar.xz
glibc-58f9551f5bac093dac2dcf3c66e32a4934ff8bd6.zip
Defeat a malloc optimization by declaring things volatile.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/tst-malloc-backtrace.c4
-rw-r--r--malloc/tst-malloc-too-large.c2
-rw-r--r--malloc/tst-malloc.c2
-rw-r--r--malloc/tst-mcheck.c2
-rw-r--r--malloc/tst-valloc.c2
5 files changed, 6 insertions, 6 deletions
diff --git a/malloc/tst-malloc-backtrace.c b/malloc/tst-malloc-backtrace.c
index 171cfcefb8..b1708b3529 100644
--- a/malloc/tst-malloc-backtrace.c
+++ b/malloc/tst-malloc-backtrace.c
@@ -35,8 +35,8 @@ call_free (void *ptr)
 int
 do_test (void)
 {
-  void *ptr1 = malloc (SIZE);
-  void *ptr2 = malloc (SIZE);
+  void *volatile ptr1 = malloc (SIZE);
+  void *volatile ptr2 = malloc (SIZE);
 
   /* Avoid unwanted output to TTY after an expected memory corruption.  */
   ignore_stderr();
diff --git a/malloc/tst-malloc-too-large.c b/malloc/tst-malloc-too-large.c
index 10fb136528..bdd2a9eebc 100644
--- a/malloc/tst-malloc-too-large.c
+++ b/malloc/tst-malloc-too-large.c
@@ -69,7 +69,7 @@ test_setup (void)
 static void
 test_large_allocations (size_t size)
 {
-  void * ptr_to_realloc;
+  void *volatile ptr_to_realloc;
 
   test_setup ();
   TEST_VERIFY (malloc (size) == NULL);
diff --git a/malloc/tst-malloc.c b/malloc/tst-malloc.c
index aa1aa2aa41..bd10351246 100644
--- a/malloc/tst-malloc.c
+++ b/malloc/tst-malloc.c
@@ -33,7 +33,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p, *q;
+  void *volatile p, *volatile q;
   int save;
 
   errno = 0;
diff --git a/malloc/tst-mcheck.c b/malloc/tst-mcheck.c
index 18b0d59bd9..d4c427bc90 100644
--- a/malloc/tst-mcheck.c
+++ b/malloc/tst-mcheck.c
@@ -33,7 +33,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p, *q;
+  void *volatile p, *volatile q;
 
   errno = 0;
 
diff --git a/malloc/tst-valloc.c b/malloc/tst-valloc.c
index ba57d9559a..b28163afe0 100644
--- a/malloc/tst-valloc.c
+++ b/malloc/tst-valloc.c
@@ -34,7 +34,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p;
+  void *volatile p;
   unsigned long pagesize = getpagesize ();
   unsigned long ptrval;
   int save;