On Mon, May 30, 2011 at 02:05:13PM -0700, Dan Fandrich wrote:
> It's not easy compiling something against bionic using the
> Android compiler outside the Android build system, but it can
> at least now happen.
> 
> Signed-off-by: Dan Fandrich <[email protected]>
> ---
> Conditionally compiling xmalloc_ttyname() is a bit ugly, but necessary
> since bionic doesn't have ttyname_r.

Plain ttyname could be used, I think. The only reason ttyname_r is
used is to avoid enlarging bss for the nasty static buffer; it's not
for reentrancy. This could also be done via HAVE_TTYNAME_R in
platform.h rather than #ifndef ANDROID (see below)...

>  /* Try to pull in PAGE_SIZE */
>  #ifdef __linux__
> -# include <sys/user.h>
> +# ifdef ANDROID
> +#  include <sys/mman.h>
> +# else
> +#  include <sys/user.h>
> +# endif

Why not get it from the correct place, limits.h? In case broken libs
(glibc?) are missing it, you could do something like:

#include <limits.h>
#ifndef PAGE_SIZE
#include <sys/user.h>
#endif

> --- a/libbb/obscure.c
> +++ b/libbb/obscure.c
> @@ -109,10 +109,12 @@ static const char *obscure_msg(const char *old_p, const 
> char *new_p, const struc
>       if (string_checker(new_p, pw->pw_name)) {
>               return "similar to username";
>       }
> +#ifndef ANDROID
>       /* no gecos as-is, as sub-string, reversed, capitalized, doubled */
>       if (pw->pw_gecos[0] && string_checker(new_p, pw->pw_gecos)) {
>               return "similar to gecos";
>       }
> +#endif

This is a really ugly legacy approach to "portability" and leads to
spaghetti #ifdefs. Instead you should add HAVE_PW_GECOS or something
and #undef it in platform.h for ANDROID. Basically, #ifdef SYSNAME or
#ifndef SYSNAME should *never* appear outside of platform.h. Currently
it does in many places, but this should be treated as a bug to be
fixed, not a practice to be followed.

Rich
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to