Skip to content

Commit 44a16fd

Browse files
committed
FIX: Cast to PyArrayObject *, warning of comparsion integers of npy_intp with ulong.
1 parent 361d480 commit 44a16fd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

devsupApp/src/dbfield.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,19 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
130130
PyArray_Descr *desc = dbf2np[paddr->field_type];
131131

132132
if(paddr->field_type==DBF_STRING &&
133-
(PyArray_NDIM(arr)!=2 || PyArray_DIM(arr,0)>maxlen || PyArray_DIM(arr,1)!=MAX_STRING_SIZE))
133+
(PyArray_NDIM((PyArrayObject *)arr) != 2 ||
134+
PyArray_DIM((PyArrayObject *)arr, 0) > (npy_intp) maxlen ||
135+
PyArray_DIM((PyArrayObject *)arr, 1) != MAX_STRING_SIZE))
134136
{
135137
PyErr_Format(PyExc_ValueError, "String array has incorrect shape or is too large");
136138
return 1;
137139

138-
} else if(PyArray_NDIM(arr)!=1 || PyArray_DIM(arr,0)>maxlen) {
140+
} else if(PyArray_NDIM((PyArrayObject *)arr) != 1 || PyArray_DIM((PyArrayObject *)arr, 0) > (npy_intp) maxlen) {
139141
PyErr_Format(PyExc_ValueError, "Array has incorrect shape or is too large");
140142
return 1;
141143
}
142144

143-
insize = PyArray_DIM(arr, 0);
145+
insize = PyArray_DIM((PyArrayObject *)arr, 0);
144146

145147
if(paddr->special==SPC_DBADDR &&
146148
(prset=dbGetRset(paddr)) &&
@@ -165,13 +167,13 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
165167
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_CARRAY, arr)))
166168
return 1;
167169

168-
if(elemsize!=PyArray_ITEMSIZE(aval)) {
170+
if(elemsize!=PyArray_ITEMSIZE((PyArrayObject *)aval)) {
169171
PyErr_Format(PyExc_AssertionError, "item size mismatch %u %u",
170-
elemsize, (unsigned)PyArray_ITEMSIZE(aval) );
172+
elemsize, (unsigned)PyArray_ITEMSIZE((PyArrayObject *)aval) );
171173
return 1;
172174
}
173175

174-
memcpy(rawfield, PyArray_GETPTR1(aval, 0), insize*elemsize);
176+
memcpy(rawfield, PyArray_GETPTR1((PyArrayObject *)aval, 0), insize*elemsize);
175177

176178
Py_DECREF(aval);
177179

0 commit comments

Comments
 (0)