On Thu, Sep 2, 2021 at 9:41 AM Rob Landley <[email protected]> wrote: > On 9/1/21 11:34 AM, Rob Landley wrote: > > I thought about typecasting it to (void) but decided to wait for a > complaint > > because A) > > > "CROSS_COMPILE=~/android/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android- > > make distclean defconfig toybox" didn't warn about it (obviously -Wall > doesn't > > mean all, that would be silly), > > So looking into this, there isn't a -Wunused-result or similar, it's that > you > have to annotate every function you want to generate this warning for with > __attribute__((warn_unused_result)) and the NDK headers don't. > > Well, there's a little annotation, via: > > sysroot/usr/include/sys/cdefs.h has > #define __wur __attribute__((__warn_unused_result__)) > > Which then appears in three other files: > > sysroot/usr/include/stdlib.h > sysroot/usr/include/malloc.h > sysroot/usr/include/sys/random.h > > I.E. > > sysroot/usr/include/stdlib.h:__wur char* realpath(const char* __path, char* > __resolved); > sysroot/usr/include/malloc.h:void* malloc(size_t __byte_count) __mallocfunc > __BIONIC_ALLOC_SIZE(1) __wur; > sysroot/usr/include/malloc.h:void* calloc(size_t __item_count, size_t > __item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur; > sysroot/usr/include/malloc.h:void* realloc(void* __ptr, size_t > __byte_count) > __BIONIC_ALLOC_SIZE(2) __wur; > sysroot/usr/include/malloc.h:void* reallocarray(void* __ptr, size_t > __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur > __INTRODUCED_IN(29); > sysroot/usr/include/malloc.h:void* memalign(size_t __alignment, size_t > __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur; > sysroot/usr/include/sys/random.h:int getentropy(void* __buffer, size_t > __buffer_size) __wur __INTRODUCED_IN(28); > sysroot/usr/include/sys/random.h:ssize_t getrandom(void* __buffer, size_t > __buffer_size, unsigned int __flags) __wur __INTRODUCED_IN(28); > > None of which is write(). > > That's why android-ndk-r21d isn't producing this warning.
yeah, sorry: this is for the _host_ toybox (so glibc right now). adding more of these to bionic has been on the to-do list for years, but turning up warnings is always a hard slog... (see my comment about updating the compiler in my previous response!) > Would upgrading to a > newer version get it, not until i add more annotations to bionic, no :-) > or is this more aosp-vs-ndk version skew? (And is there an > easy way to build external packages with the AOSP prebuilt toolchain?) > if you actually find yourself in a situation where bionic has something that isn't in the NDK yet, it's probably easier to update the sysroot (which only requires an NDK manifest checkout, not a full AOSP manifest checkout): https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md#updating-the-sysroot > Rob > _______________________________________________ > Toybox mailing list > [email protected] > http://lists.landley.net/listinfo.cgi/toybox-landley.net >
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
