bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] tar-1.31/lib/stdopen.c:63]: (style) Suspicious condition


From: Ralph Corderoy
Subject: Re: [Bug-tar] tar-1.31/lib/stdopen.c:63]: (style) Suspicious condition
Date: Thu, 03 Jan 2019 15:17:29 +0000

Hello David,

> Source code is
>        if (mode == O_RDONLY
>                   || (new_fd = open ("/dev/full", mode) != fd))
>
> Maybe better code
>        if (mode == O_RDONLY
>                   || ((new_fd = open ("/dev/full", mode)) != fd))

That's changing the written meaning.  The original means

    new_fd = (open("/dev/full", mode) != fd)

because `!=' is higher precedence than `=' so one can write

    good = foo != bar || xyzzy;

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]