MAINT: Fix LGTM.com warning: Comparison result is always the same (res)#19944
Merged
charris merged 1 commit intoSep 24, 2021
Merged
Conversation
res)
Member
|
This might be clearer if |
Comparison result is always the same
Comparison is always false because res <= 0.
Indeed the for(;;) iteration may stop on 3 different breaks:
res = -1;
break;
if (!res) {
break;
if (!res) {
break;
Therefore, after the loop, the only possible values for res are -1 and 0,
and (res > 0) is always false.
This originates in 37dc69c (numpy#17029).
47da8f8 to
580bbdf
Compare
Contributor
Author
|
Clearer indeed. Changed to |
Member
|
Thanks @DimitriPapadopoulos . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://lgtm.com/projects/g/numpy/numpy/snapshot/6fd377657ac7fcc9d244e2d1ebae26e70f60db51/files/numpy/core/src/multiarray/ctors.c?sort=name&dir=ASC&mode=heatmap#xa080a7fcc79c74e4:1
Indeed the
for(;;)loop may stop on 3 different breaks:Therefore, after the loop, the only possible values for
resare -1 and 0, and(res > 0)is always false.This originates in 37dc69c (#17029).