Tidy up KernelArgumentBlock::getauxval.
Correct the comment, and remove the unused functionality. getauxval(3) does
now set errno to let you know it failed to find anything, but since none of
this function's callers care anyway it seems safer to leave errno untouched
until we actually have a demonstrated need for it.
Bug: https://code.google.com/p/android/issues/detail?id=198111
Change-Id: I232a42dc5a02c8faab94c7d69bef610408276c23
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index c8ea497..68d4999 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -38,32 +38,25 @@
argv = reinterpret_cast<char**>(args + 1);
envp = argv + argc + 1;
- // Skip over all environment variable definitions to find aux vector.
- // The end of the environment block is marked by two NULL pointers.
+ // Skip over all environment variable definitions to find the aux vector.
+ // The end of the environment block is marked by a NULL pointer.
char** p = envp;
while (*p != NULL) {
++p;
}
- ++p; // Skip second NULL;
+ ++p; // Skip the NULL itself.
auxv = reinterpret_cast<ElfW(auxv_t)*>(p);
}
// Similar to ::getauxval but doesn't require the libc global variables to be set up,
- // so it's safe to call this really early on. This function also lets you distinguish
- // between the inability to find the given type and its value just happening to be 0.
- unsigned long getauxval(unsigned long type, bool* found_match = NULL) {
+ // so it's safe to call this really early on.
+ unsigned long getauxval(unsigned long type) {
for (ElfW(auxv_t)* v = auxv; v->a_type != AT_NULL; ++v) {
if (v->a_type == type) {
- if (found_match != NULL) {
- *found_match = true;
- }
return v->a_un.a_val;
}
}
- if (found_match != NULL) {
- *found_match = false;
- }
return 0;
}