develooper Front page | perl.perl5.porters | Postings from September 2017

Re: [perl #132153] perl-5.26.1/doio.c:1529]: (style) Suspiciouscondition

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
September 24, 2017 08:52
Subject:
Re: [perl #132153] perl-5.26.1/doio.c:1529]: (style) Suspiciouscondition
Message ID:
CAHhgV8ibaU7eQyZcqEB+ghH0L3cYno0QMiy=0qG-LkYJ=jLWCQ@mail.gmail.com
On Sun, Sep 24, 2017 at 12:43 AM, David Binderman <perlbug-followup@perl.org
> wrote:

> Hello there,
>
>
> perl-5.26.1/doio.c:1529]: (style) Suspicious condition (assignment +
> comparison); Clarify expression with parentheses.
>
>
> Source code is
>
>
>     if ( (  (SvROK(sv) && (  isGV_with_GP(SvRV(sv))
>                           || (isio = SvTYPE(SvRV(sv)) == SVt_PVIO)  )
>
>
>
I can see why why your compiler/linter could conclude that looks
suspicious,but it looks entirely correct to me.


> Maybe better code
>
>
>     if ( (  (SvROK(sv) && (  isGV_with_GP(SvRV(sv))
>                           || ((isio = SvTYPE(SvRV(sv))) == SVt_PVIO)  )
>
>
No, that's exactly the wrong thing to do. If we add parentheses to please
your compiler/linter, they should be around the comparison, not around the
assignment.

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About