Skip to content

Commit

Permalink
MAINT: Fix LGTM.com warning
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
DimitriPapadopoulos committed Sep 24, 2021
1 parent 0cf5bc0 commit 580bbdf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
/* If we exhausted the dst block, refresh it */
if (dst_count == count) {
res = dst_iternext(dst_iter);
if (!res) {
if (res == 0) {
break;
}
dst_count = *dst_countptr;
Expand All @@ -2731,7 +2731,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
/* If we exhausted the src block, refresh it */
if (src_count == count) {
res = src_iternext(src_iter);
if (!res) {
if (res == 0) {
break;
}
src_count = *src_countptr;
Expand All @@ -2748,10 +2748,6 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
NPY_cast_info_xfree(&cast_info);
NpyIter_Deallocate(dst_iter);
NpyIter_Deallocate(src_iter);
if (res > 0) {
/* The iteration stopped successfully, do not report an error */
return 0;
}
return res;
}

Expand Down

0 comments on commit 580bbdf

Please sign in to comment.