diff options
| author | Elliott Hughes <enh@google.com> | 2015-01-22 01:52:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-22 01:52:06 +0000 |
| commit | d1668a71df761eb1644496f3e2c77c16fd54bb06 (patch) | |
| tree | 9acfbeb2c5fc1e858bed6db341004df078a2d4ab /libc/bionic/libc_init_common.cpp | |
| parent | 4f11c59b3f3acffe6c8e359296a9e38c4b7edfb6 (diff) | |
| parent | 8b5df3920f2843c9cdf04160517c1e8b77c992f5 (diff) | |
| download | bionic-d1668a71df761eb1644496f3e2c77c16fd54bb06.zip bionic-d1668a71df761eb1644496f3e2c77c16fd54bb06.tar.gz bionic-d1668a71df761eb1644496f3e2c77c16fd54bb06.tar.bz2 | |
Merge "Turn on -Wold-style-cast and fix the errors."
Diffstat (limited to 'libc/bionic/libc_init_common.cpp')
| -rw-r--r-- | libc/bionic/libc_init_common.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp index 94b7dd2..f82ec73 100644 --- a/libc/bionic/libc_init_common.cpp +++ b/libc/bionic/libc_init_common.cpp @@ -129,33 +129,34 @@ void __libc_init_common(KernelArgumentBlock& args) { * entry in the list has value -1, the last one has value 0. */ void __libc_fini(void* array) { - void** fini_array = reinterpret_cast<void**>(array); - const size_t minus1 = ~(size_t)0; /* ensure proper sign extension */ + typedef void (*Dtor)(); + Dtor* fini_array = reinterpret_cast<Dtor*>(array); + const Dtor minus1 = reinterpret_cast<Dtor>(static_cast<uintptr_t>(-1)); - /* Sanity check - first entry must be -1 */ - if (array == NULL || (size_t)fini_array[0] != minus1) { + // Sanity check - first entry must be -1. + if (array == NULL || fini_array[0] != minus1) { return; } - /* skip over it */ + // Skip over it. fini_array += 1; - /* Count the number of destructors. */ + // Count the number of destructors. int count = 0; while (fini_array[count] != NULL) { ++count; } - /* Now call each destructor in reverse order. */ + // Now call each destructor in reverse order. while (count > 0) { - void (*func)() = (void (*)()) fini_array[--count]; + Dtor dtor = fini_array[--count]; - /* Sanity check, any -1 in the list is ignored */ - if ((size_t)func == minus1) { + // Sanity check, any -1 in the list is ignored. + if (dtor == minus1) { continue; } - func(); + dtor(); } #ifndef LIBC_STATIC |
