-
Notifications
You must be signed in to change notification settings - Fork 601
re_op_compile: Coverity ASSIGN_WHERE_COMPARE_MEANT fix #19672
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
Conversation
|
Well this isn't just a refactor, it's a change in behaviour. Previously, sawlookahead was set if two conditions were true: OP(first) == IFMATCH && !first->flags; now it just needs the first condition. I have no idea whether it matters, but if it doesn't, I'd prefer this as two commits - a pure refactor, followed by removing of the extra test which (allegedly) isn't needed. |
I was thinking that, w.r.t
I could do something around that second case if so. |
|
Alternatively, would structuring it like this be acceptable? |
|
On Sun, May 01, 2022 at 04:14:05PM -0700, Richard Leach wrote:
Alternatively, would structuring it like this be acceptable?
Perhaps. But I think for non-buggy code it's probably best to just let
sleeping dogs lie as far as possible. Can Coverity be satisfied by using
double parens, as in:
while ((OP(first) == OPEN && ((sawopen = 1)) ) ||
...
…--
You're only as old as you look.
|
I'll set up a Coverity project and find out. |
|
I haven't gotten around to setting up a Coverity project, nor am I likely to do so imminently. Almost identical other Coverity warnings have been marked as false positives in the project, so perhaps the most expedient thing to do here is do the same? |
|
On Wed, 27 Apr 2022, 07:16 Richard Leach, ***@***.***> wrote:
Coverity CID 316368 raises the concern that in the following comparison:
(OP(first) == OPEN && (sawopen = 1)
the intention might have been to compare sawopen, not assign to it.
I think this might just need double parens on the expr. Afaik that is an
established way of telling the compiler the assignment is intended. I'm
guessing that the && is confusing things. Also this style is very heavily
used in our regexp code, and refactoring it can be quite difficult and
often results in much harder to read code.
The intention genuinely is to assign to sawopen, but since there are two
… assignments in this fashion followed by two assignments in the subsequent
block, we can do a small refactor to consolidate the assignments in a way
that will hopefully keep Coverity happy.
------------------------------
You can view, comment on, or merge this pull request online at:
#19672
Commit Summary
- 3b44327
<3b44327>
re_op_compile: Coverity ASSIGN_WHERE_COMPARE_MEANT fix
File Changes
(1 file <https://github.com/Perl/perl5/pull/19672/files>)
- *M* regcomp.c
<https://github.com/Perl/perl5/pull/19672/files#diff-dc8c62daf844c4b19510dfce777053a52ac4821852ef9818e3de8912dd3c4edb>
(19)
Patch Links:
- https://github.com/Perl/perl5/pull/19672.patch
- https://github.com/Perl/perl5/pull/19672.diff
—
Reply to this email directly, view it on GitHub
<#19672>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAZ5R44CC5ZU6PWFLCSE73VHB2OFANCNFSM5UNLDM5A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Oh @iabyn already said that. My bad for replying before reading the full thread. Not enough coffee this morning. Sorry @richardleach . |
3b44327 to
fb12a1c
Compare
|
I've updated the PR with just additional parens as recommended. |
Coverity CID 316368 raises the concern that in the following comparison:
(OP(first) == OPEN && (sawopen = 1)the intention might have been to compare sawopen, not assign to it.
The intention genuinely is to assign to sawopen, but since there are two
assignments in this fashion followed by two assignments in the subsequent
block, we can do a small refactor to consolidate the assignments in a way
that will hopefully keep Coverity happy.