[Toybox] [PATCH] tar: Fix support for long symbolic links

enh enh at google.com
Thu Mar 21 14:51:38 PDT 2019


On Thu, Mar 21, 2019 at 1:24 PM Rob Landley <rob at landley.net> wrote:
>
> On 3/21/19 10:29 AM, enh wrote:
> > https://github.com/landley/toybox/commit/14eee98d9dbe81729437bf333ea413b43e37969a#diff-2c433160b0e21dc043bae1484ee3077bL215
> > switched to strncpy, but that patch upset clang:
> >
> > external/toybox/toys/pending/tar.c:549:49: error: '&&' within '||'
> > [-Werror,-Wlogical-op-parentheses]
> >     if (filter(TT.excl, TT.hdr.name) || TT.incl && !delete) skippy(TT.hdr.size);
> >                                      ~~ ~~~~~~~~^~~~~~~~~~
> >
> > it's way too early in the morning for me to work out what was intended there...
>
> && has higher priority than || so it's doing exactly what it should be doing? I
> dunno why the compiler is so upset. I can see the if (x = blah()) warning
> because that's an easy typo to make, but && and || are not easily typoed...?
> (Nor are - and & which it warns about mixing now. Give it time and it'll warn
> about mixing + and * without parentheses.)

i think + and * are about all you can assume readers (and writers)
actually know the precedence of.

> Compilers maintained by C++ developers demand gratuitous parentheses despite
> defined operator precedence because C++ developers are not to be trusted and
> this warning is enabled even for C code. They you have -Werror enabled so it
> becomes an error...
>
> (I note that I could hold off checking in any of the changes until it's done and
> just do a single flag day change. If that's how I should clean up commands
> Android's using out of pending, I can do that? I don't want to inconvenience you
> guys more than necessary...)

i don't think there's a clear answer either way. i think it's just an
unfortunate coincidence that someone else is trying to fix a bug in
tar at the exact same time.

> Rob


More information about the Toybox mailing list