about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCarlos Eduardo Seo <carlos.seo@arm.com>2022-01-26 16:00:13 -0300
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-11-22 14:24:26 +0000
commit17034ac2bf79f415150b5b32b0e2bf24b8636267 (patch)
tree39193655d0f5bb1426fc324ea6d134db5678222c
parent13de83e5cfee8c5f79e04e10e22b88959481e50b (diff)
downloadglibc-17034ac2bf79f415150b5b32b0e2bf24b8636267.tar.gz
glibc-17034ac2bf79f415150b5b32b0e2bf24b8636267.tar.xz
glibc-17034ac2bf79f415150b5b32b0e2bf24b8636267.zip
malloc: Use uintptr_t for pointer alignment
Avoid integer casts that assume unsigned long can represent pointers.
-rw-r--r--malloc/arena.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/malloc/arena.c b/malloc/arena.c
index 0a684a720d..b1f5b4117f 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -444,7 +444,7 @@ dump_heap (heap_info *heap)
   fprintf (stderr, "Heap %p, size %10lx:\n", heap, (long) heap->size);
   ptr = (heap->ar_ptr != (mstate) (heap + 1)) ?
         (char *) (heap + 1) : (char *) (heap + 1) + sizeof (struct malloc_state);
-  p = (mchunkptr) (((unsigned long) ptr + MALLOC_ALIGN_MASK) &
+  p = (mchunkptr) (((uintptr_t) ptr + MALLOC_ALIGN_MASK) &
                    ~MALLOC_ALIGN_MASK);
   for (;; )
     {
@@ -518,7 +518,7 @@ alloc_new_heap  (size_t size, size_t top_pad, size_t pagesize,
       p1 = (char *) MMAP (0, max_size << 1, PROT_NONE, mmap_flags);
       if (p1 != MAP_FAILED)
         {
-          p2 = (char *) (((unsigned long) p1 + (max_size - 1))
+          p2 = (char *) (((uintptr_t) p1 + (max_size - 1))
                          & ~(max_size - 1));
           ul = p2 - p1;
           if (ul)
@@ -760,7 +760,7 @@ _int_new_arena (size_t size)
 
   /* Set up the top chunk, with proper alignment. */
   ptr = (char *) (a + 1);
-  misalign = (unsigned long) chunk2mem (ptr) & MALLOC_ALIGN_MASK;
+  misalign = (uintptr_t) chunk2mem (ptr) & MALLOC_ALIGN_MASK;
   if (misalign > 0)
     ptr += MALLOC_ALIGNMENT - misalign;
   top (a) = (mchunkptr) ptr;