diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2013-12-19 10:25:23 -0800 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2013-12-19 10:25:23 -0800 |
commit | 063b2acbce83549df82ab30f5af573f1b9c4bd19 (patch) | |
tree | 795d2ba571bc60fe139f9b48327f63c3ec7eae2f /elf | |
parent | 21fea2e228c4e6f83bf51133de72f70fc61a6b6c (diff) | |
download | glibc-063b2acbce83549df82ab30f5af573f1b9c4bd19.zip glibc-063b2acbce83549df82ab30f5af573f1b9c4bd19.tar.gz glibc-063b2acbce83549df82ab30f5af573f1b9c4bd19.tar.bz2 |
Cleanup compile warnings.
2013-12-19 Paul Pluzhnikov <ppluzhnikov@google.com>
* elf/dl-misc.c (ptr_to_signal_safe_allocator_header): New function.
(__signal_safe_memalign, __signal_safe_free): Use it.
(__signal_safe_realloc): Likewise.
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-misc.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/elf/dl-misc.c b/elf/dl-misc.c index cec65d0..e5c76a7 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -380,15 +380,23 @@ struct __signal_safe_allocator_header void *start; }; +static inline struct __signal_safe_allocator_header * +ptr_to_signal_safe_allocator_header (void *ptr) +{ + return (struct __signal_safe_allocator_header *) + ((char *) (ptr) - sizeof (struct __signal_safe_allocator_header)); +} + void *weak_function __signal_safe_memalign (size_t boundary, size_t size) { struct __signal_safe_allocator_header *header; + if (boundary < sizeof (*header)) boundary = sizeof (*header); /* Boundary must be a power of two. */ - if (boundary & (boundary - 1) == 0) + if ((boundary & (boundary - 1)) == 0) return NULL; size_t pg = GLRO (dl_pagesize); @@ -432,9 +440,9 @@ __signal_safe_memalign (size_t boundary, size_t size) actual = (void *) ((start_pg - 1) * pg); } char *start = (void *) (start_pg * pg); - header = start - sizeof (*header); - + header = ptr_to_signal_safe_allocator_header (start); } + header->size = actual_size; header->start = actual; void *ptr = header; @@ -456,7 +464,8 @@ __signal_safe_free (void *ptr) if (ptr == NULL) return; - struct __signal_safe_allocator_header *header = ((char *) ptr) - sizeof (*header); + struct __signal_safe_allocator_header *header + = ptr_to_signal_safe_allocator_header (ptr); int ret = munmap (header->start, header->size); assert (ret == 0); @@ -473,7 +482,8 @@ __signal_safe_realloc (void *ptr, size_t size) if (ptr == NULL) return __signal_safe_malloc (size); - struct __signal_safe_allocator_header *header = ((char *) ptr) - sizeof (*header); + struct __signal_safe_allocator_header *header + = ptr_to_signal_safe_allocator_header (ptr); size_t old_size = header->size; if (old_size - sizeof (*header) >= size) return ptr; |