summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-01-31 12:25:11 -0700
committerGitHub <noreply@github.com>2018-01-31 12:25:11 -0700
commit1706056ab7e3bc321f3bc6f605fdbd6a55fb3c42 (patch)
tree7da188c6f1425d7c17f02899bb0d37bd01a0532d /numpy/core/src
parentb6975e1588e5d7a3e23c8d440981a0929dd1a97e (diff)
parent02391c3bd04e0ce5e376aa8f1fa35f1f01fffc50 (diff)
downloadnumpy-1706056ab7e3bc321f3bc6f605fdbd6a55fb3c42.tar.gz
Merge pull request #10465 from charris/fix-sign-compare-misc
MAINT: Fix miscellaneous sign-compare warnings.
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/array_assign_scalar.c2
-rw-r--r--numpy/core/src/multiarray/common.c2
-rw-r--r--numpy/core/src/multiarray/multiarray_tests.c.src4
-rw-r--r--numpy/core/src/multiarray/refcount.c4
-rw-r--r--numpy/core/src/multiarray/shape.c4
-rw-r--r--numpy/core/src/multiarray/temp_elide.c6
6 files changed, 15 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/array_assign_scalar.c b/numpy/core/src/multiarray/array_assign_scalar.c
index 7c1b1f16a..3d259ae05 100644
--- a/numpy/core/src/multiarray/array_assign_scalar.c
+++ b/numpy/core/src/multiarray/array_assign_scalar.c
@@ -233,7 +233,7 @@ PyArray_AssignRawScalar(PyArrayObject *dst,
* Use a static buffer to store the aligned/cast version,
* or allocate some memory if more space is needed.
*/
- if (sizeof(scalarbuffer) >= PyArray_DESCR(dst)->elsize) {
+ if ((int)sizeof(scalarbuffer) >= PyArray_DESCR(dst)->elsize) {
tmp_src_data = (char *)&scalarbuffer[0];
}
else {
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c
index 099cc0394..10efdc4c8 100644
--- a/numpy/core/src/multiarray/common.c
+++ b/numpy/core/src/multiarray/common.c
@@ -588,7 +588,7 @@ _zerofill(PyArrayObject *ret)
NPY_NO_EXPORT int
_IsAligned(PyArrayObject *ap)
{
- unsigned int i;
+ int i;
npy_uintp aligned;
npy_uintp alignment = PyArray_DESCR(ap)->alignment;
diff --git a/numpy/core/src/multiarray/multiarray_tests.c.src b/numpy/core/src/multiarray/multiarray_tests.c.src
index e223b2c7c..d63349560 100644
--- a/numpy/core/src/multiarray/multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/multiarray_tests.c.src
@@ -8,6 +8,8 @@
#include "npy_extint128.h"
#include "common.h"
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
/* test PyArray_IsPythonScalar, before including private py3 compat header */
static PyObject *
IsPythonScalar(PyObject * dummy, PyObject *args)
@@ -1036,7 +1038,7 @@ array_solve_diophantine(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject
return NULL;
}
- if (PyTuple_GET_SIZE(A) > sizeof(terms) / sizeof(diophantine_term_t)) {
+ if (PyTuple_GET_SIZE(A) > (Py_ssize_t)ARRAY_SIZE(terms)) {
PyErr_SetString(PyExc_ValueError, "too many terms in equation");
goto fail;
}
diff --git a/numpy/core/src/multiarray/refcount.c b/numpy/core/src/multiarray/refcount.c
index 88f660118..4b018b056 100644
--- a/numpy/core/src/multiarray/refcount.c
+++ b/numpy/core/src/multiarray/refcount.c
@@ -276,7 +276,9 @@ _fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype)
}
else {
npy_intp i;
- for (i = 0; i < dtype->elsize / sizeof(obj); i++) {
+ npy_intp nsize = dtype->elsize / sizeof(obj);
+
+ for (i = 0; i < nsize; i++) {
Py_XINCREF(obj);
NPY_COPY_PYOBJECT_PTR(optr, &obj);
optr += sizeof(obj);
diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c
index 40925d8b9..61908e95e 100644
--- a/numpy/core/src/multiarray/shape.c
+++ b/numpy/core/src/multiarray/shape.c
@@ -339,7 +339,9 @@ _putzero(char *optr, PyObject *zero, PyArray_Descr *dtype)
}
else {
npy_intp i;
- for (i = 0; i < dtype->elsize / sizeof(zero); i++) {
+ npy_intp nsize = dtype->elsize / sizeof(zero);
+
+ for (i = 0; i < nsize; i++) {
Py_INCREF(zero);
NPY_COPY_PYOBJECT_PTR(optr, &zero);
optr += sizeof(zero);
diff --git a/numpy/core/src/multiarray/temp_elide.c b/numpy/core/src/multiarray/temp_elide.c
index e5175f162..3d2f976f2 100644
--- a/numpy/core/src/multiarray/temp_elide.c
+++ b/numpy/core/src/multiarray/temp_elide.c
@@ -7,6 +7,7 @@
#include "numpy/arrayobject.h"
#define NPY_NUMBER_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
/*
* Functions used to try to avoid/elide temporaries in python expressions
@@ -181,6 +182,7 @@ check_callers(int * cannot)
Dl_info info;
int in_python = 0;
int in_multiarray = 0;
+
#if NPY_ELIDE_DEBUG >= 2
dladdr(buffer[i], &info);
printf("%s(%p) %s(%p)\n", info.dli_fname, info.dli_fbase,
@@ -242,14 +244,14 @@ check_callers(int * cannot)
}
if (info.dli_sname &&
strcmp(info.dli_sname, PYFRAMEEVAL_FUNC) == 0) {
- if (n_pyeval < sizeof(pyeval_addr) / sizeof(pyeval_addr[0])) {
+ if (n_pyeval < (npy_intp)ARRAY_SIZE(pyeval_addr)) {
/* store address to not have to dladdr it again */
pyeval_addr[n_pyeval++] = buffer[i];
}
ok = 1;
break;
}
- else if (n_py_addr < sizeof(py_addr) / sizeof(py_addr[0])) {
+ else if (n_py_addr < (npy_intp)ARRAY_SIZE(py_addr)) {
/* store other py function to not have to dladdr it again */
py_addr[n_py_addr++] = buffer[i];
}