Changes for #inclusivefixit.
Test: treehugger
Change-Id: I7ff0496c5c2792a41781e74634247f55b0548213
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 1ede969..f1350d5 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -359,10 +359,8 @@
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 == nullptr || fini_array[0] != minus1) {
- return;
- }
+ // Validity check: the first entry must be -1.
+ if (array == nullptr || fini_array[0] != minus1) return;
// Skip over it.
fini_array += 1;
@@ -373,15 +371,9 @@
++count;
}
- // Now call each destructor in reverse order.
+ // Now call each destructor in reverse order, ignoring any -1s.
while (count > 0) {
Dtor dtor = fini_array[--count];
-
- // Sanity check, any -1 in the list is ignored.
- if (dtor == minus1) {
- continue;
- }
-
- dtor();
+ if (dtor != minus1) dtor();
}
}