<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 2, 2021 at 9:41 AM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 9/1/21 11:34 AM, Rob Landley wrote:<br>
> I thought about typecasting it to (void) but decided to wait for a complaint<br>
> because A)<br>
> "CROSS_COMPILE=~/android/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-<br>
> make distclean defconfig toybox" didn't warn about it (obviously -Wall doesn't<br>
> mean all, that would be silly),<br>
<br>
So looking into this, there isn't a -Wunused-result or similar, it's that you<br>
have to annotate every function you want to generate this warning for with<br>
__attribute__((warn_unused_result)) and the NDK headers don't.<br>
<br>
Well, there's a little annotation, via:<br>
<br>
sysroot/usr/include/sys/cdefs.h has<br>
#define __wur __attribute__((__warn_unused_result__))<br>
<br>
Which then appears in three other files:<br>
<br>
sysroot/usr/include/stdlib.h<br>
sysroot/usr/include/malloc.h<br>
sysroot/usr/include/sys/random.h<br>
<br>
I.E.<br>
<br>
sysroot/usr/include/stdlib.h:__wur char* realpath(const char* __path, char*<br>
__resolved);<br>
sysroot/usr/include/malloc.h:void* malloc(size_t __byte_count) __mallocfunc<br>
__BIONIC_ALLOC_SIZE(1) __wur;<br>
sysroot/usr/include/malloc.h:void* calloc(size_t __item_count, size_t<br>
__item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;<br>
sysroot/usr/include/malloc.h:void* realloc(void* __ptr, size_t __byte_count)<br>
__BIONIC_ALLOC_SIZE(2) __wur;<br>
sysroot/usr/include/malloc.h:void* reallocarray(void* __ptr, size_t<br>
__item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur<br>
__INTRODUCED_IN(29);<br>
sysroot/usr/include/malloc.h:void* memalign(size_t __alignment, size_t<br>
__byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;<br>
sysroot/usr/include/sys/random.h:int getentropy(void* __buffer, size_t<br>
__buffer_size) __wur __INTRODUCED_IN(28);<br>
sysroot/usr/include/sys/random.h:ssize_t getrandom(void* __buffer, size_t<br>
__buffer_size, unsigned int __flags) __wur __INTRODUCED_IN(28);<br>
<br>
None of which is write().<br>
<br>
That's why android-ndk-r21d isn't producing this warning. </blockquote><div><br></div><div>yeah, sorry: this is for the _host_ toybox (so glibc right now).</div><div><br></div><div>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!)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Would upgrading to a<br>
newer version get it, </blockquote><div><br></div><div><div>not until i add more annotations to bionic, no :-)</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">or is this more aosp-vs-ndk version skew? (And is there an<br>
easy way to build external packages with the AOSP prebuilt toolchain?)<br></blockquote><div><br></div><div>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):</div><div><br></div><div><a href="https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md#updating-the-sysroot">https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md#updating-the-sysroot</a></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Rob<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div></div>