[PATCH] Use correct type for glibc.malloc.perturb in tst-tunconf1.c

Stefan Liebler <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
On s390x the test elf/tunconf1 fails with:
tst-tunconf1.c:41: numeric comparison failure (widths 64 and 32)
   left: 180388626436 (0x2a00000004); from: (long)perturb
  right: 42 (0x2a); from: 42

According to elf/dl-tunables.list, glibc.malloc.perturb is of type int32_t (4byte)
and not size_t (8byte) which was used for TUNABLE_GET_FULL inside the testcase.
Therefore the correct 32bit value 0x2a=42 is written to the to the wrong place
and leads to the comparison failure.
---
 elf/tst-tunconf1.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/elf/tst-tunconf1.c b/elf/tst-tunconf1.c
index 74f596d913..3b3152e0b2 100644
--- a/elf/tst-tunconf1.c
+++ b/elf/tst-tunconf1.c
@@ -26,7 +26,7 @@ do_test (void)
 {
   size_t tcache_count = TUNABLE_GET_FULL (glibc, malloc, tcache_count, size_t, NULL);
   size_t tcache_max = TUNABLE_GET_FULL (glibc, malloc, tcache_max, size_t, NULL);
-  size_t perturb = TUNABLE_GET_FULL (glibc, malloc, perturb, size_t, NULL);
+  int32_t perturb = TUNABLE_GET_FULL (glibc, malloc, perturb, int32_t, NULL);
   size_t mmap_threshold = TUNABLE_GET_FULL (glibc, malloc, mmap_threshold, size_t, NULL);
   size_t trim_threshold = TUNABLE_GET_FULL (glibc, malloc, trim_threshold, size_t, NULL);
 
@@ -36,9 +36,9 @@ do_test (void)
   TEST_COMPARE ((long)tcache_max, 4);
 
   /* This is set by the environment but blocked by the config.  */
-  printf("perturb is %ld (should be 42, from /etc)\n",
-	 (long)perturb);
-  TEST_COMPARE ((long)perturb, 42);
+  printf("perturb is %d (should be 42, from /etc)\n",
+	 perturb);
+  TEST_COMPARE (perturb, 42);
 
   /* This is blocked by the general config, enabled by filter, set in env.  */
   printf("mmap_threshold is %ld (should be 10002, from env)\n",
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.