[PATCH 4/6] android: fix 'stat', ifdef S_TYPEIS* in coreutiles/stat.c

Rich Felker dalias at aerifal.cx
Mon May 28 23:31:39 UTC 2012


On Mon, May 28, 2012 at 11:44:32PM +0200, Tias Guns wrote:
> +#ifndef __ANDROID__
>  	if (S_TYPEISMQ(st))        return "message queue";
>  	if (S_TYPEISSEM(st))       return "semaphore";
>  	if (S_TYPEISSHM(st))       return "shared memory object";
> +#endif

Instead of encoding system-specific knowledge like this in the source
files, you should do:

#ifdef S_TYPEISMQ
 	if (S_TYPEISMQ(st))        return "message queue";
#endif
#ifdef S_TYPEISSEM
 	if (S_TYPEISSEM(st))        return "semaphore";
#endif
...

Not only will this avoid hideous 1980s-style source uglification where
each source file is full of all sorts of ugly platform-specific
knowledge; it will also make it so the features are immediately
available if Android ever does add them (whereas your version would
leave them off on Android until somebody fixes it, then it would have
to be changed to something even more hideous like #if
__ANDROID_VERSION > xxx ...).

Note that the code RIGHT BELOW your changes does this exactly the
right way...

Rich


More information about the busybox mailing list