Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl-5.26.1/doio.c:1529]: (style) Suspicious condition #16168

Open
p5pRT opened this issue Sep 23, 2017 · 4 comments
Open

perl-5.26.1/doio.c:1529]: (style) Suspicious condition #16168

p5pRT opened this issue Sep 23, 2017 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 23, 2017

Migrated from rt.perl.org#132153 (status was 'open')

Searchable as RT132153$

@p5pRT
Copy link
Author

p5pRT commented Sep 23, 2017

From dcb314@hotmail.com

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

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2017

From @jkeenan

On Sat, 23 Sep 2017 22​:43​:07 GMT, dcb314@​hotmail.com 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) )

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)

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2017

From @Leont

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants