From 63fbb233cbdf0f0d6fb6ce23234f5fc75855ba85 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 5 Jan 2016 16:29:33 -0800 Subject: [PATCH] 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 --- libc/private/KernelArgumentBlock.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h index c8ea4977a..68d499999 100644 --- a/libc/private/KernelArgumentBlock.h +++ b/libc/private/KernelArgumentBlock.h @@ -38,32 +38,25 @@ class KernelArgumentBlock { argv = reinterpret_cast(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(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; }