Skip Menu |
Report information
Id: 132153
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: dcb314 [at] hotmail.com
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



To: "perlbug [...] perl.org" <perlbug [...] perl.org>
Date: Sat, 23 Sep 2017 14:11:25 +0000
Subject: perl-5.26.1/doio.c:1529]: (style) Suspicious condition
From: David Binderman <dcb314 [...] hotmail.com>
Download (untitled) / with headers
text/plain 450b

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)  )


Maybe better code


    if ( (  (SvROK(sv) && (  isGV_with_GP(SvRV(sv))
                          || ((isio = SvTYPE(SvRV(sv))) == SVt_PVIO)  )


Regards


David Binderman


RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 854b
On Sat, 23 Sep 2017 22:43:07 GMT, dcb314@hotmail.com wrote: Show quoted text
> 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) ) > > > Maybe better code > > > if ( ( (SvROK(sv) && ( isGV_with_GP(SvRV(sv)) > || ((isio = SvTYPE(SvRV(sv))) == SVt_PVIO) ) > > > Regards > > > David Binderman
Can you provide (as an attachment) the output of 'perl -V' for the perl build that generated this warning? We will, in particular, be looking for information on the C compiler you used for 'make' and the operating system on which you are running. Thank you very much. -- James E Keenan (jkeenan@cpan.org)
To: Perl5 Porters <perl5-porters [...] perl.org>
CC: "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
Date: Sun, 24 Sep 2017 10:52:11 +0200
Subject: Re: [perl #132153] perl-5.26.1/doio.c:1529]: (style) Suspicious condition
From: Leon Timmermans <fawaka [...] gmail.com>
Download (untitled) / with headers
text/plain 824b
On Sun, Sep 24, 2017 at 12:43 AM, David Binderman <perlbug-followup@perl.org> wrote:
Show quoted text
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.
 
Show quoted text
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org