Skip to content

Commit 580bbdf

Browse files
MAINT: Fix LGTM.com warning
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).
1 parent 0cf5bc0 commit 580bbdf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

numpy/core/src/multiarray/ctors.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
27172717
/* If we exhausted the dst block, refresh it */
27182718
if (dst_count == count) {
27192719
res = dst_iternext(dst_iter);
2720-
if (!res) {
2720+
if (res == 0) {
27212721
break;
27222722
}
27232723
dst_count = *dst_countptr;
@@ -2731,7 +2731,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
27312731
/* If we exhausted the src block, refresh it */
27322732
if (src_count == count) {
27332733
res = src_iternext(src_iter);
2734-
if (!res) {
2734+
if (res == 0) {
27352735
break;
27362736
}
27372737
src_count = *src_countptr;
@@ -2748,10 +2748,6 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
27482748
NPY_cast_info_xfree(&cast_info);
27492749
NpyIter_Deallocate(dst_iter);
27502750
NpyIter_Deallocate(src_iter);
2751-
if (res > 0) {
2752-
/* The iteration stopped successfully, do not report an error */
2753-
return 0;
2754-
}
27552751
return res;
27562752
}
27572753

0 commit comments

Comments
 (0)