[Toybox] [PATCH] macOS: replace local strnstr with strcasestr.

enh enh at google.com
Mon Dec 3 10:00:19 PST 2018


amusingly, the same line causes a (different) compile-time warning
with old versions of glibc. glibc 2.15 at least has mktemp marked as
warn_unused_result, and AOSP currently uses glibc 2.15 for host
builds. i've sent a patch to fix that (and attached the same patch
here too, in case the spam filter is still messing with you :-) ).

someone's looking at upgrading the host glibc, but 2.15 is just inside
the 7-year rule. plus i assume you'll be happy to save a line anyway.
i'm not sure why i didn't write it as one line in the first place...
even i don't find it obfuscatory in this case.
On Mon, Dec 3, 2018 at 8:27 AM enh <enh at google.com> wrote:
>
> On Sun, Dec 2, 2018 at 2:57 PM Rob Landley <rob at landley.net> wrote:
> >
> > On 12/1/18 12:48 AM, enh wrote:
> > >> /opt/android/x86_64/bin/../sysroot/usr/include/stdlib.h:68:47: note: 'mktemp'
> > >>       has been explicitly marked deprecated here
> > >> char* mktemp(char* __template) __attribute__((deprecated("mktemp is unsa...
> > >>                                               ^
> > >> 1 warning generated.
> > >>
> > >> Why is it unsafe? (musl and glibc don't complain...)
> > >
> > > dunno about musl, but glibc does (just at link time rather than
> > > compile time --- iirc we no longer have any link-time warnings in
> > > bionic, just compile time ones).
> >
> > Um, _you_ added this warning in commit 40a09367f6f9.
>
> yes, i know. mktemp(3) is the correct implementation of mktemp(1) -u.
> the old implementation (which actually created a file) is observably
> different, subject to the exact same race anyway, and doesn't work if
> you can't write to the directory (and if that's what someone was
> trying to do, they wouldn't^Wshouldn't be using -u in the first
> place).
>
> like i said, this is one of the reasons why bionic doesn't use
> link-time warnings: there's no targeted way to say "this specific case
> is fine" like you can with a compiler warning, it's all or nothing.
>
> > -  if (d_flag ? !mkdtemp(template) : mkstemp(template) == -1) {
> > +  if (toys.optflags & FLAG_u) {
> > +    mktemp(template);
> >
> > Why did you do that? (What's the issue you were trying to solve, exactly?)
> >
> > Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mktemp-fix-warning-with-glibc-2.15.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20181203/21f127a6/attachment-0003.bin>


More information about the Toybox mailing list