summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-01-29 09:58:16 -0800
committerMark Wiebe <mwwiebe@gmail.com>2011-01-29 10:57:49 -0800
commit08fdf3b8ff613ad51af21e53de915c232bb395e4 (patch)
tree4db8082868fcec4ca53752d014e35c071d51fe19 /numpy/core
parentcb7e0acab944d8b43550ae060b5ab888042c4954 (diff)
downloadnumpy-08fdf3b8ff613ad51af21e53de915c232bb395e4.tar.gz
WRN: core: Remove many warnings gcc produces with stricter flags
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/descriptor.c31
-rw-r--r--numpy/core/src/multiarray/dtype_transfer.c221
-rw-r--r--numpy/core/src/multiarray/einsum.c.src2
-rw-r--r--numpy/core/src/multiarray/item_selection.c14
-rw-r--r--numpy/core/src/multiarray/new_iterator.c.src64
-rw-r--r--numpy/core/src/npymath/npy_math_complex.c.src6
-rw-r--r--numpy/core/src/scalarmathmodule.c.src8
7 files changed, 183 insertions, 163 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 7cbcd7866..bf4ea27a6 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -576,7 +576,7 @@ static NPY_DATETIMEUNIT
return unit;
}
-static int _multiples_table[16][4] = {
+static NPY_DATETIMEUNIT _multiples_table[16][4] = {
{12, 52, 365}, /* NPY_FR_Y */
{NPY_FR_M, NPY_FR_W, NPY_FR_D},
{4, 30, 720}, /* NPY_FR_M */
@@ -601,13 +601,13 @@ static int
_convert_divisor_to_multiple(PyArray_DatetimeMetaData *meta)
{
int i, num, ind;
- int *totry;
+ NPY_DATETIMEUNIT *totry;
NPY_DATETIMEUNIT *baseunit;
int q, r;
ind = ((int)meta->base - (int)NPY_FR_Y)*2;
totry = _multiples_table[ind];
- baseunit = (NPY_DATETIMEUNIT *)_multiples_table[ind + 1];
+ baseunit = _multiples_table[ind + 1];
num = 3;
if (meta->base == NPY_FR_W) {
@@ -619,7 +619,7 @@ _convert_divisor_to_multiple(PyArray_DatetimeMetaData *meta)
if (meta->base >= NPY_FR_s) {
ind = ((int)NPY_FR_s - (int)NPY_FR_Y)*2;
totry = _multiples_table[ind];
- baseunit = (NPY_DATETIMEUNIT *)_multiples_table[ind + 1];
+ baseunit = _multiples_table[ind + 1];
baseunit[0] = meta->base + 1;
baseunit[1] = meta->base + 2;
if (meta->base == NPY_DATETIME_NUMUNITS - 2) {
@@ -705,7 +705,7 @@ _convert_from_datetime_tuple(PyObject *obj)
PyArray_Descr *new;
PyObject *dt_tuple;
PyObject *dt_cobj;
- PyObject *datetime;
+ PyObject *datetime_flag;
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj)!=2) {
PyErr_SetString(PyExc_RuntimeError,
@@ -714,10 +714,10 @@ _convert_from_datetime_tuple(PyObject *obj)
}
dt_tuple = PyTuple_GET_ITEM(obj, 0);
- datetime = PyTuple_GET_ITEM(obj, 1);
+ datetime_flag = PyTuple_GET_ITEM(obj, 1);
if (!PyTuple_Check(dt_tuple)
|| PyTuple_GET_SIZE(dt_tuple) != 4
- || !PyInt_Check(datetime)) {
+ || !PyInt_Check(datetime_flag)) {
PyErr_SetString(PyExc_RuntimeError,
"_datetimestring is not returning a length 4 tuple"\
" and an integer");
@@ -725,7 +725,7 @@ _convert_from_datetime_tuple(PyObject *obj)
}
/* Create new timedelta or datetime dtype */
- if (PyObject_IsTrue(datetime)) {
+ if (PyObject_IsTrue(datetime_flag)) {
new = PyArray_DescrNewFromType(PyArray_DATETIME);
}
else {
@@ -1814,15 +1814,12 @@ arraydescr_metadata_get(PyArray_Descr *self)
static PyObject *
arraydescr_hasobject_get(PyArray_Descr *self)
{
- PyObject *res;
if (PyDataType_FLAGCHK(self, NPY_ITEM_HASOBJECT)) {
- res = Py_True;
+ Py_RETURN_TRUE;
}
else {
- res = Py_False;
+ Py_RETURN_FALSE;
}
- Py_INCREF(res);
- return res;
}
static PyObject *
@@ -2693,10 +2690,10 @@ arraydescr_str(PyArray_Descr *self)
PyObject *sh;
p = arraydescr_str(self->subarray->base);
if (!self->subarray->base->names && !self->subarray->base->subarray) {
- PyObject *t=PyUString_FromString("'");
- PyUString_Concat(&p, t);
- PyUString_ConcatAndDel(&t, p);
- p = t;
+ PyObject *tmp=PyUString_FromString("'");
+ PyUString_Concat(&p, tmp);
+ PyUString_ConcatAndDel(&tmp, p);
+ p = tmp;
}
PyUString_ConcatAndDel(&t, p);
PyUString_ConcatAndDel(&t, PyUString_FromString(","));
diff --git a/numpy/core/src/multiarray/dtype_transfer.c b/numpy/core/src/multiarray/dtype_transfer.c
index 9074a2160..cf8409500 100644
--- a/numpy/core/src/multiarray/dtype_transfer.c
+++ b/numpy/core/src/multiarray/dtype_transfer.c
@@ -37,7 +37,7 @@
") <- BIG PROBLEM!!!!" : ")") : ""); \
fflush(stdout);
#else
-#define NPY_DT_DBG_REFTRACE(...)
+#define NPY_DT_DBG_REFTRACE(msg, ref)
#endif
/**********************************************/
@@ -137,15 +137,18 @@ _strided_to_strided_copy_references(char *dst, npy_intp dst_stride,
/************************** ZERO-PADDED COPY ******************************/
+typedef void (*free_strided_transfer_data)(void *);
+typedef void *(*copy_strided_transfer_data)(void *);
+
/* Does a zero-padded copy */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
npy_intp dst_itemsize;
} _strided_zero_pad_data;
/* zero-padded data copy function */
-_strided_zero_pad_data *_strided_zero_pad_data_copy(
- _strided_zero_pad_data *data)
+void *_strided_zero_pad_data_copy(void *data)
{
_strided_zero_pad_data *newdata =
(_strided_zero_pad_data *)PyArray_malloc(
@@ -220,7 +223,8 @@ PyArray_GetStridedZeroPadCopyFn(int aligned,
/* Wraps a transfer function + data in alignment code */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_StridedTransferFn *wrapped,
*tobuffer, *frombuffer;
void *wrappeddata, *todata, *fromdata;
@@ -229,17 +233,19 @@ typedef struct {
} _align_wrap_data;
/* transfer data free function */
-void _align_wrap_data_free(_align_wrap_data *data)
+void _align_wrap_data_free(void *data)
{
- PyArray_FreeStridedTransferData(data->wrappeddata);
- PyArray_FreeStridedTransferData(data->todata);
- PyArray_FreeStridedTransferData(data->fromdata);
+ _align_wrap_data *d = (_align_wrap_data *)data;
+ PyArray_FreeStridedTransferData(d->wrappeddata);
+ PyArray_FreeStridedTransferData(d->todata);
+ PyArray_FreeStridedTransferData(d->fromdata);
PyArray_free(data);
}
/* transfer data copy function */
-_align_wrap_data *_align_wrap_data_copy(_align_wrap_data *data)
+void *_align_wrap_data_copy(void *data)
{
+ _align_wrap_data *d = (_align_wrap_data *)data;
_align_wrap_data *newdata;
npy_intp basedatasize, datasize;
@@ -247,8 +253,8 @@ _align_wrap_data *_align_wrap_data_copy(_align_wrap_data *data)
basedatasize = (sizeof(_align_wrap_data)+15)&(-0x10);
/* Add space for two low level buffers */
datasize = basedatasize +
- NPY_LOWLEVEL_BUFFER_BLOCKSIZE*data->src_itemsize +
- NPY_LOWLEVEL_BUFFER_BLOCKSIZE*data->dst_itemsize;
+ NPY_LOWLEVEL_BUFFER_BLOCKSIZE*d->src_itemsize +
+ NPY_LOWLEVEL_BUFFER_BLOCKSIZE*d->dst_itemsize;
/* Allocate the data, and populate it */
newdata = (_align_wrap_data *)PyArray_malloc(datasize);
@@ -261,14 +267,14 @@ _align_wrap_data *_align_wrap_data_copy(_align_wrap_data *data)
NPY_LOWLEVEL_BUFFER_BLOCKSIZE*newdata->src_itemsize;
if (newdata->wrappeddata != NULL) {
newdata->wrappeddata =
- PyArray_CopyStridedTransferData(data->wrappeddata);
+ PyArray_CopyStridedTransferData(d->wrappeddata);
if (newdata->wrappeddata == NULL) {
PyArray_free(newdata);
return NULL;
}
}
if (newdata->todata != NULL) {
- newdata->todata = PyArray_CopyStridedTransferData(data->todata);
+ newdata->todata = PyArray_CopyStridedTransferData(d->todata);
if (newdata->todata == NULL) {
PyArray_FreeStridedTransferData(newdata->wrappeddata);
PyArray_free(newdata);
@@ -276,7 +282,7 @@ _align_wrap_data *_align_wrap_data_copy(_align_wrap_data *data)
}
}
if (newdata->fromdata != NULL) {
- newdata->fromdata = PyArray_CopyStridedTransferData(data->fromdata);
+ newdata->fromdata = PyArray_CopyStridedTransferData(d->fromdata);
if (newdata->fromdata == NULL) {
PyArray_FreeStridedTransferData(newdata->wrappeddata);
PyArray_FreeStridedTransferData(newdata->todata);
@@ -285,7 +291,7 @@ _align_wrap_data *_align_wrap_data_copy(_align_wrap_data *data)
}
}
- return newdata;
+ return (void *)newdata;
}
static void
@@ -417,8 +423,8 @@ wrap_aligned_contig_transfer_function(
PyErr_NoMemory();
return NPY_FAIL;
}
- data->freefunc = (void *)&_align_wrap_data_free;
- data->copyfunc = (void *)&_align_wrap_data_copy;
+ data->freefunc = &_align_wrap_data_free;
+ data->copyfunc = &_align_wrap_data_copy;
data->tobuffer = tobuffer;
data->todata = todata;
data->frombuffer = frombuffer;
@@ -446,21 +452,23 @@ wrap_aligned_contig_transfer_function(
/*************************** WRAP DTYPE COPY/SWAP *************************/
/* Wraps the dtype copy swap function */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_CopySwapNFunc *copyswapn;
int swap;
PyArrayObject *arr;
} _wrap_copy_swap_data;
/* wrap copy swap data free function */
-void _wrap_copy_swap_data_free(_wrap_copy_swap_data *data)
+void _wrap_copy_swap_data_free(void *data)
{
- Py_DECREF(data->arr);
+ _wrap_copy_swap_data *d = (_wrap_copy_swap_data *)data;
+ Py_DECREF(d->arr);
PyArray_free(data);
}
/* wrap copy swap data copy function */
-_wrap_copy_swap_data *_wrap_copy_swap_data_copy(_wrap_copy_swap_data *data)
+void *_wrap_copy_swap_data_copy(void *data)
{
_wrap_copy_swap_data *newdata =
(_wrap_copy_swap_data *)PyArray_malloc(sizeof(_wrap_copy_swap_data));
@@ -471,7 +479,7 @@ _wrap_copy_swap_data *_wrap_copy_swap_data_copy(_wrap_copy_swap_data *data)
memcpy(newdata, data, sizeof(_wrap_copy_swap_data));
Py_INCREF(newdata->arr);
- return newdata;
+ return (void *)newdata;
}
static void
@@ -533,21 +541,23 @@ wrap_copy_swap_function(int aligned,
/* Does a simple aligned cast */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_VectorUnaryFunc *castfunc;
PyArrayObject *aip, *aop;
} _strided_cast_data;
/* strided cast data free function */
-void _strided_cast_data_free(_strided_cast_data *data)
+void _strided_cast_data_free(void *data)
{
- Py_DECREF(data->aip);
- Py_DECREF(data->aop);
+ _strided_cast_data *d = (_strided_cast_data *)data;
+ Py_DECREF(d->aip);
+ Py_DECREF(d->aop);
PyArray_free(data);
}
/* strided cast data copy function */
-_strided_cast_data *_strided_cast_data_copy(_strided_cast_data *data)
+void *_strided_cast_data_copy(void *data)
{
_strided_cast_data *newdata =
(_strided_cast_data *)PyArray_malloc(sizeof(_strided_cast_data));
@@ -559,7 +569,7 @@ _strided_cast_data *_strided_cast_data_copy(_strided_cast_data *data)
Py_INCREF(newdata->aip);
Py_INCREF(newdata->aop);
- return newdata;
+ return (void *)newdata;
}
static void
@@ -731,8 +741,8 @@ get_nbo_cast_transfer_function(int aligned,
*out_transferdata = NULL;
return NPY_FAIL;
}
- data->freefunc = (void*)&_strided_cast_data_free;
- data->copyfunc = (void*)&_strided_cast_data_copy;
+ data->freefunc = &_strided_cast_data_free;
+ data->copyfunc = &_strided_cast_data_copy;
data->castfunc = castfunc;
/*
* TODO: This is a hack so the cast functions have an array.
@@ -948,7 +958,8 @@ get_cast_transfer_function(int aligned,
/* Copies 1 element to N contiguous elements */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_StridedTransferFn *stransfer;
void *data;
npy_intp N, dst_itemsize;
@@ -958,16 +969,18 @@ typedef struct {
} _one_to_n_data;
/* transfer data free function */
-void _one_to_n_data_free(_one_to_n_data *data)
+void _one_to_n_data_free(void *data)
{
- PyArray_FreeStridedTransferData(data->data);
- PyArray_FreeStridedTransferData(data->data_finish_src);
+ _one_to_n_data *d = (_one_to_n_data *)data;
+ PyArray_FreeStridedTransferData(d->data);
+ PyArray_FreeStridedTransferData(d->data_finish_src);
PyArray_free(data);
}
/* transfer data copy function */
-_one_to_n_data *_one_to_n_data_copy(_one_to_n_data *data)
+void *_one_to_n_data_copy(void *data)
{
+ _one_to_n_data *d = (_one_to_n_data *)data;
_one_to_n_data *newdata;
/* Allocate the data, and populate it */
@@ -976,16 +989,16 @@ _one_to_n_data *_one_to_n_data_copy(_one_to_n_data *data)
return NULL;
}
memcpy(newdata, data, sizeof(_one_to_n_data));
- if (data->data != NULL) {
- newdata->data = PyArray_CopyStridedTransferData(data->data);
+ if (d->data != NULL) {
+ newdata->data = PyArray_CopyStridedTransferData(d->data);
if (newdata->data == NULL) {
PyArray_free(newdata);
return NULL;
}
}
- if (data->data_finish_src != NULL) {
+ if (d->data_finish_src != NULL) {
newdata->data_finish_src =
- PyArray_CopyStridedTransferData(data->data_finish_src);
+ PyArray_CopyStridedTransferData(d->data_finish_src);
if (newdata->data_finish_src == NULL) {
PyArray_FreeStridedTransferData(newdata->data);
PyArray_free(newdata);
@@ -993,7 +1006,7 @@ _one_to_n_data *_one_to_n_data_copy(_one_to_n_data *data)
}
}
- return newdata;
+ return (void *)newdata;
}
static void
@@ -1153,22 +1166,25 @@ get_one_to_n_transfer_function(int aligned,
/* Copies N contiguous elements to N contiguous elements */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_StridedTransferFn *stransfer;
void *data;
npy_intp N, src_itemsize, dst_itemsize;
} _n_to_n_data;
/* transfer data free function */
-void _n_to_n_data_free(_n_to_n_data *data)
+void _n_to_n_data_free(void *data)
{
- PyArray_FreeStridedTransferData(data->data);
+ _n_to_n_data *d = (_n_to_n_data *)data;
+ PyArray_FreeStridedTransferData(d->data);
PyArray_free(data);
}
/* transfer data copy function */
-_n_to_n_data *_n_to_n_data_copy(_n_to_n_data *data)
+void *_n_to_n_data_copy(void *data)
{
+ _n_to_n_data *d = (_n_to_n_data *)data;
_n_to_n_data *newdata;
/* Allocate the data, and populate it */
@@ -1178,14 +1194,14 @@ _n_to_n_data *_n_to_n_data_copy(_n_to_n_data *data)
}
memcpy(newdata, data, sizeof(_n_to_n_data));
if (newdata->data != NULL) {
- newdata->data = PyArray_CopyStridedTransferData(data->data);
+ newdata->data = PyArray_CopyStridedTransferData(d->data);
if (newdata->data == NULL) {
PyArray_free(newdata);
return NULL;
}
}
- return newdata;
+ return (void *)newdata;
}
static void
@@ -1323,7 +1339,8 @@ typedef struct {
/* Copies element with subarray broadcasting */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
PyArray_StridedTransferFn *stransfer;
void *data;
npy_intp src_N, dst_N, src_itemsize, dst_itemsize;
@@ -1337,20 +1354,21 @@ typedef struct {
} _subarray_broadcast_data;
/* transfer data free function */
-void _subarray_broadcast_data_free(_subarray_broadcast_data *data)
+void _subarray_broadcast_data_free(void *data)
{
- PyArray_FreeStridedTransferData(data->data);
- PyArray_FreeStridedTransferData(data->data_decsrcref);
- PyArray_FreeStridedTransferData(data->data_decdstref);
+ _subarray_broadcast_data *d = (_subarray_broadcast_data *)data;
+ PyArray_FreeStridedTransferData(d->data);
+ PyArray_FreeStridedTransferData(d->data_decsrcref);
+ PyArray_FreeStridedTransferData(d->data_decdstref);
PyArray_free(data);
}
/* transfer data copy function */
-_subarray_broadcast_data *_subarray_broadcast_data_copy(
- _subarray_broadcast_data *data)
+void *_subarray_broadcast_data_copy( void *data)
{
+ _subarray_broadcast_data *d = (_subarray_broadcast_data *)data;
_subarray_broadcast_data *newdata;
- npy_intp run_count = data->run_count, structsize;
+ npy_intp run_count = d->run_count, structsize;
structsize = sizeof(_subarray_broadcast_data) +
run_count*sizeof(_subarray_broadcast_offsetrun);
@@ -1361,25 +1379,25 @@ _subarray_broadcast_data *_subarray_broadcast_data_copy(
return NULL;
}
memcpy(newdata, data, structsize);
- if (data->data != NULL) {
- newdata->data = PyArray_CopyStridedTransferData(data->data);
+ if (d->data != NULL) {
+ newdata->data = PyArray_CopyStridedTransferData(d->data);
if (newdata->data == NULL) {
PyArray_free(newdata);
return NULL;
}
}
- if (data->data_decsrcref != NULL) {
+ if (d->data_decsrcref != NULL) {
newdata->data_decsrcref =
- PyArray_CopyStridedTransferData(data->data_decsrcref);
+ PyArray_CopyStridedTransferData(d->data_decsrcref);
if (newdata->data_decsrcref == NULL) {
PyArray_FreeStridedTransferData(newdata->data);
PyArray_free(newdata);
return NULL;
}
}
- if (data->data_decdstref != NULL) {
+ if (d->data_decdstref != NULL) {
newdata->data_decdstref =
- PyArray_CopyStridedTransferData(data->data_decdstref);
+ PyArray_CopyStridedTransferData(d->data_decdstref);
if (newdata->data_decdstref == NULL) {
PyArray_FreeStridedTransferData(newdata->data);
PyArray_FreeStridedTransferData(newdata->data_decsrcref);
@@ -1403,16 +1421,16 @@ _strided_to_strided_subarray_broadcast(char *dst, npy_intp dst_stride,
npy_intp run, run_count = d->run_count,
src_subitemsize = d->src_itemsize,
dst_subitemsize = d->dst_itemsize;
- npy_intp index, offset, count;
+ npy_intp loop_index, offset, count;
char *dst_ptr;
_subarray_broadcast_offsetrun *offsetruns = &d->offsetruns;
while (N > 0) {
- index = 0;
+ loop_index = 0;
for (run = 0; run < run_count; ++run) {
offset = offsetruns[run].offset;
count = offsetruns[run].count;
- dst_ptr = dst + index*dst_subitemsize;
+ dst_ptr = dst + loop_index*dst_subitemsize;
if (offset != -1) {
subtransfer(dst_ptr, dst_subitemsize,
src + offset, src_subitemsize,
@@ -1422,7 +1440,7 @@ _strided_to_strided_subarray_broadcast(char *dst, npy_intp dst_stride,
else {
memset(dst_ptr, 0, count*dst_subitemsize);
}
- index += count;
+ loop_index += count;
}
src += src_stride;
@@ -1449,16 +1467,16 @@ _strided_to_strided_subarray_broadcast_withrefs(char *dst, npy_intp dst_stride,
src_subitemsize = d->src_itemsize,
dst_subitemsize = d->dst_itemsize,
src_subN = d->src_N;
- npy_intp index, offset, count;
+ npy_intp loop_index, offset, count;
char *dst_ptr;
_subarray_broadcast_offsetrun *offsetruns = &d->offsetruns;
while (N > 0) {
- index = 0;
+ loop_index = 0;
for (run = 0; run < run_count; ++run) {
offset = offsetruns[run].offset;
count = offsetruns[run].count;
- dst_ptr = dst + index*dst_subitemsize;
+ dst_ptr = dst + loop_index*dst_subitemsize;
if (offset != -1) {
subtransfer(dst_ptr, dst_subitemsize,
src + offset, src_subitemsize,
@@ -1473,7 +1491,7 @@ _strided_to_strided_subarray_broadcast_withrefs(char *dst, npy_intp dst_stride,
}
memset(dst_ptr, 0, count*dst_subitemsize);
}
- index += count;
+ loop_index += count;
}
if (stransfer_decsrcref != NULL) {
@@ -1501,7 +1519,8 @@ get_subarray_broadcast_transfer_function(int aligned,
int *out_needs_api)
{
_subarray_broadcast_data *data;
- npy_intp structsize, index, run, run_size, src_index, dst_index, i, ndim;
+ npy_intp structsize, loop_index, run, run_size,
+ src_index, dst_index, i, ndim;
_subarray_broadcast_offsetrun *offsetruns;
structsize = sizeof(_subarray_broadcast_data) +
@@ -1577,10 +1596,10 @@ get_subarray_broadcast_transfer_function(int aligned,
/* Calculate the broadcasting and set the offsets */
offsetruns = &data->offsetruns;
ndim = (src_shape.len > dst_shape.len) ? src_shape.len : dst_shape.len;
- for (index = 0; index < dst_size; ++index) {
+ for (loop_index = 0; loop_index < dst_size; ++loop_index) {
npy_intp src_factor = 1;
- dst_index = index;
+ dst_index = loop_index;
src_index = 0;
for (i = ndim-1; i >= 0; --i) {
npy_intp coord = 0, shape;
@@ -1613,24 +1632,24 @@ get_subarray_broadcast_transfer_function(int aligned,
}
/* Set the offset */
if (src_index == -1) {
- offsetruns[index].offset = -1;
+ offsetruns[loop_index].offset = -1;
}
else {
- offsetruns[index].offset = src_index;
+ offsetruns[loop_index].offset = src_index;
}
}
/* Run-length encode the result */
run = 0;
run_size = 1;
- for (index = 1; index < dst_size; ++index) {
+ for (loop_index = 1; loop_index < dst_size; ++loop_index) {
if (offsetruns[run].offset == -1) {
/* Stop the run when there's a valid index again */
- if (offsetruns[index].offset != -1) {
+ if (offsetruns[loop_index].offset != -1) {
offsetruns[run].count = run_size;
run++;
run_size = 1;
- offsetruns[run].offset = offsetruns[index].offset;
+ offsetruns[run].offset = offsetruns[loop_index].offset;
}
else {
run_size++;
@@ -1638,11 +1657,12 @@ get_subarray_broadcast_transfer_function(int aligned,
}
else {
/* Stop the run when there's a valid index again */
- if (offsetruns[index].offset != offsetruns[index-1].offset + 1) {
+ if (offsetruns[loop_index].offset !=
+ offsetruns[loop_index-1].offset + 1) {
offsetruns[run].count = run_size;
run++;
run_size = 1;
- offsetruns[run].offset = offsetruns[index].offset;
+ offsetruns[run].offset = offsetruns[loop_index].offset;
}
else {
run_size++;
@@ -1783,30 +1803,35 @@ typedef struct {
} _single_field_transfer;
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
npy_intp field_count;
_single_field_transfer fields;
} _field_transfer_data;
/* transfer data free function */
-void _field_transfer_data_free(_field_transfer_data *data)
+void _field_transfer_data_free(void *data)
{
- npy_intp i, field_count = data->field_count;
- _single_field_transfer *fields = &data->fields;
+ _field_transfer_data *d = (_field_transfer_data *)data;
+ npy_intp i, field_count;
+ _single_field_transfer *fields;
+
+ field_count = d->field_count;
+ fields = &d->fields;
for (i = 0; i < field_count; ++i) {
PyArray_FreeStridedTransferData(fields[i].data);
}
- PyArray_free(data);
+ PyArray_free(d);
}
/* transfer data copy function */
-_field_transfer_data *_field_transfer_data_copy(
- _field_transfer_data *data)
+void *_field_transfer_data_copy(void *data)
{
+ _field_transfer_data *d = (_field_transfer_data *)data;
_field_transfer_data *newdata;
- npy_intp i, field_count = data->field_count, structsize;
+ npy_intp i, field_count = d->field_count, structsize;
_single_field_transfer *fields, *newfields;
structsize = sizeof(_field_transfer_data) +
@@ -1817,9 +1842,9 @@ _field_transfer_data *_field_transfer_data_copy(
if (newdata == NULL) {
return NULL;
}
- memcpy(newdata, data, structsize);
+ memcpy(newdata, d, structsize);
/* Copy all the fields transfer data */
- fields = &data->fields;
+ fields = &d->fields;
newfields = &newdata->fields;
for (i = 0; i < field_count; ++i) {
if (fields[i].data != NULL) {
@@ -1836,7 +1861,7 @@ _field_transfer_data *_field_transfer_data_copy(
}
- return newdata;
+ return (void *)newdata;
}
static void
@@ -2442,13 +2467,13 @@ get_bool_setdstone_transfer_function(npy_intp dst_stride,
/* Sets dest to zero */
typedef struct {
- void *freefunc, *copyfunc;
+ free_strided_transfer_data freefunc;
+ copy_strided_transfer_data copyfunc;
npy_intp dst_itemsize;
} _dst_memset_zero_data;
/* zero-padded data copy function */
-_dst_memset_zero_data *_dst_memset_zero_data_copy(
- _dst_memset_zero_data *data)
+void *_dst_memset_zero_data_copy(void *data)
{
_dst_memset_zero_data *newdata =
(_dst_memset_zero_data *)PyArray_malloc(
@@ -2561,8 +2586,8 @@ get_setdstzero_transfer_function(int aligned,
else if (dst_dtype->subarray != NULL) {
PyArray_Dims dst_shape = {NULL, -1};
npy_intp dst_size = 1;
- PyArray_StridedTransferFn *stransfer;
- void *data;
+ PyArray_StridedTransferFn *contig_stransfer;
+ void *contig_data;
if (out_needs_api) {
*out_needs_api = 1;
@@ -2581,17 +2606,17 @@ get_setdstzero_transfer_function(int aligned,
if (get_setdstzero_transfer_function(aligned,
dst_dtype->subarray->base->elsize,
dst_dtype->subarray->base,
- &stransfer, &data,
+ &contig_stransfer, &contig_data,
out_needs_api) != NPY_SUCCEED) {
return NPY_FAIL;
}
- if (wrap_transfer_function_n_to_n(stransfer, data,
+ if (wrap_transfer_function_n_to_n(contig_stransfer, contig_data,
0, dst_stride,
0, dst_dtype->subarray->base->elsize,
dst_size,
out_stransfer, out_transferdata) != NPY_SUCCEED) {
- PyArray_FreeStridedTransferData(data);
+ PyArray_FreeStridedTransferData(contig_data);
return NPY_FAIL;
}
}
diff --git a/numpy/core/src/multiarray/einsum.c.src b/numpy/core/src/multiarray/einsum.c.src
index f13ff6d21..7f7abcd3f 100644
--- a/numpy/core/src/multiarray/einsum.c.src
+++ b/numpy/core/src/multiarray/einsum.c.src
@@ -2199,7 +2199,7 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
* a view instead of a copy.
*/
if (iop == 0 && nop == 1 && out == NULL) {
- PyArrayObject *ret = NULL;
+ ret = NULL;
if (!get_single_op_view(op_in[iop], iop, labels,
ndim_output, output_labels,
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index c1e914ca5..6d4e0305f 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -1606,11 +1606,13 @@ PyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)
* my_diagonal.append (diagonal (a [i], offset))
* return array (my_diagonal)
*/
- PyObject *mydiagonal = NULL, *new = NULL, *ret = NULL, *sel = NULL;
- intp i, n1;
+ PyObject *mydiagonal = NULL, *ret = NULL, *sel = NULL;
+ intp n1;
int res;
PyArray_Descr *typecode;
+ new = NULL;
+
typecode = self->descr;
mydiagonal = PyList_New(0);
if (mydiagonal == NULL) {
@@ -1798,16 +1800,16 @@ PyArray_Nonzero(PyArrayObject *self)
/* If it's a one-dimensional result, don't use an iterator */
if (ndim <= 1) {
- npy_intp i;
+ npy_intp j;
coords = (npy_intp *)PyArray_DATA(ret);
data = PyArray_BYTES(self);
stride = (ndim == 0) ? 0 : PyArray_STRIDE(self, 0);
count = (ndim == 0) ? 1 : PyArray_DIM(self, 0);
- for (i = 0; i < count; ++i) {
+ for (j = 0; j < count; ++j) {
if (nonzero(data, self)) {
- *coords++ = i;
+ *coords++ = j;
}
data += stride;
}
@@ -1878,7 +1880,7 @@ finish:
}
else {
for (i = 0; i < ndim; ++i) {
- npy_intp stride = ndim*NPY_SIZEOF_INTP;
+ stride = ndim*NPY_SIZEOF_INTP;
PyArrayObject *view;
view = (PyArrayObject *)PyArray_New(Py_TYPE(self), 1,
diff --git a/numpy/core/src/multiarray/new_iterator.c.src b/numpy/core/src/multiarray/new_iterator.c.src
index a8e4eda8b..87eb2c599 100644
--- a/numpy/core/src/multiarray/new_iterator.c.src
+++ b/numpy/core/src/multiarray/new_iterator.c.src
@@ -1663,8 +1663,6 @@ npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter)
ptrs = NBF_PTRS(bufferdata);
- //NpyIter_DebugPrint(iter);
-
/*
* If the iterator handles the inner loop, need to increment all
* the coordinates and pointers
@@ -1672,7 +1670,7 @@ npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter)
if (!(itflags&NPY_ITFLAG_NOINNER)) {
/* Increment within the buffer */
if (++NIT_ITERINDEX(iter) < NBF_BUFITEREND(bufferdata)) {
- npy_intp iiter, *strides;
+ npy_intp *strides;
strides = NBF_STRIDES(bufferdata);
for (iiter = 0; iiter < niter; ++iiter) {
@@ -2993,8 +2991,6 @@ npyiter_prepare_operands(npy_intp niter, PyArrayObject **op_in,
}
}
if (all_null) {
- npy_intp i;
-
for (i = 0; i < niter; ++i) {
Py_XDECREF(op[i]);
Py_XDECREF(op_dtype[i]);
@@ -3953,8 +3949,8 @@ npyiter_find_best_axis_ordering(NpyIter *iter)
npy_intp idim, ndim = NIT_NDIM(iter);
npy_intp iiter, niter = NIT_NITER(iter);
- npy_intp i0, i1, ipos;
- char j0, j1;
+ npy_intp ax_i0, ax_i1, ax_ipos;
+ char ax_j0, ax_j1;
char *perm;
NpyIter_AxisData *axisdata = NIT_AXISDATA(iter);
npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter);
@@ -3967,21 +3963,21 @@ npyiter_find_best_axis_ordering(NpyIter *iter)
* the AXISDATA has been reversed from C order, this
* is sorting from smallest stride to biggest stride.
*/
- for (i0 = 1; i0 < ndim; ++i0) {
+ for (ax_i0 = 1; ax_i0 < ndim; ++ax_i0) {
npy_intp *strides0;
- /* 'ipos' is where perm[i0] will get inserted */
- ipos = i0;
- j0 = perm[i0];
+ /* 'ax_ipos' is where perm[ax_i0] will get inserted */
+ ax_ipos = ax_i0;
+ ax_j0 = perm[ax_i0];
- strides0 = NAD_STRIDES(NIT_INDEX_AXISDATA(axisdata, j0));
- for (i1 = i0-1; i1 >= 0; --i1) {
+ strides0 = NAD_STRIDES(NIT_INDEX_AXISDATA(axisdata, ax_j0));
+ for (ax_i1 = ax_i0-1; ax_i1 >= 0; --ax_i1) {
int ambig = 1, shouldswap = 0;
npy_intp *strides1;
- j1 = perm[i1];
+ ax_j1 = perm[ax_i1];
- strides1 = NAD_STRIDES(NIT_INDEX_AXISDATA(axisdata, j1));
+ strides1 = NAD_STRIDES(NIT_INDEX_AXISDATA(axisdata, ax_j1));
for (iiter = 0; iiter < niter; ++iiter) {
if (strides0[iiter] != 0 && strides1[iiter] != 0) {
@@ -4010,12 +4006,12 @@ npyiter_find_best_axis_ordering(NpyIter *iter)
}
/*
* If the comparison was unambiguous, either shift
- * 'ipos' to 'i1' or stop looking for an insertion
+ * 'ax_ipos' to 'ax_i1' or stop looking for an insertion
* point
*/
if (!ambig) {
if (shouldswap) {
- ipos = i1;
+ ax_ipos = ax_i1;
}
else {
break;
@@ -4023,12 +4019,12 @@ npyiter_find_best_axis_ordering(NpyIter *iter)
}
}
- /* Insert perm[i0] into the right place */
- if (ipos != i0) {
- for (i1 = i0; i1 > ipos; --i1) {
- perm[i1] = perm[i1-1];
+ /* Insert perm[ax_i0] into the right place */
+ if (ax_ipos != ax_i0) {
+ for (ax_i1 = ax_i0; ax_i1 > ax_ipos; --ax_i1) {
+ perm[ax_i1] = perm[ax_i1-1];
}
- perm[ipos] = j0;
+ perm[ax_ipos] = ax_j0;
permuted = 1;
}
}
@@ -5785,7 +5781,7 @@ NpyIter_DebugPrint(NpyIter *iter)
PyGILState_STATE gilstate = PyGILState_Ensure();
printf("\n------ BEGIN ITERATOR DUMP ------\n");
- printf("| Iterator Address: %p\n", iter);
+ printf("| Iterator Address: %p\n", (void *)iter);
printf("| ItFlags: ");
if (itflags&NPY_ITFLAG_IDENTPERM)
printf("IDENTPERM ");
@@ -5837,7 +5833,7 @@ NpyIter_DebugPrint(NpyIter *iter)
printf("\n");
printf("| DTypes: ");
for (iiter = 0; iiter < niter; ++iiter) {
- printf("%p ", NIT_DTYPES(iter)[iiter]);
+ printf("%p ", (void *)NIT_DTYPES(iter)[iiter]);
}
printf("\n");
printf("| DTypes: ");
@@ -5851,7 +5847,7 @@ NpyIter_DebugPrint(NpyIter *iter)
printf("\n");
printf("| InitDataPtrs: ");
for (iiter = 0; iiter < niter; ++iiter) {
- printf("%p ", NIT_RESETDATAPTR(iter)[iiter]);
+ printf("%p ", (void *)NIT_RESETDATAPTR(iter)[iiter]);
}
printf("\n");
printf("| BaseOffsets: ");
@@ -5865,7 +5861,7 @@ NpyIter_DebugPrint(NpyIter *iter)
}
printf("| Operands: ");
for (iiter = 0; iiter < niter; ++iiter) {
- printf("%p ", NIT_OPERANDS(iter)[iiter]);
+ printf("%p ", (void *)NIT_OPERANDS(iter)[iiter]);
}
printf("\n");
printf("| Operand DTypes: ");
@@ -5923,7 +5919,7 @@ NpyIter_DebugPrint(NpyIter *iter)
printf("\n");
printf("| Ptrs: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_PTRS(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_PTRS(bufferdata)[iiter]);
printf("\n");
if (itflags&NPY_ITFLAG_REDUCE) {
printf("| REDUCE Outer Strides: ");
@@ -5932,28 +5928,28 @@ NpyIter_DebugPrint(NpyIter *iter)
printf("\n");
printf("| REDUCE Outer Ptrs: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_REDUCE_OUTERPTRS(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_REDUCE_OUTERPTRS(bufferdata)[iiter]);
printf("\n");
}
printf("| ReadTransferFn: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_READTRANSFERFN(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_READTRANSFERFN(bufferdata)[iiter]);
printf("\n");
printf("| ReadTransferData: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_READTRANSFERDATA(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_READTRANSFERDATA(bufferdata)[iiter]);
printf("\n");
printf("| WriteTransferFn: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_WRITETRANSFERFN(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_WRITETRANSFERFN(bufferdata)[iiter]);
printf("\n");
printf("| WriteTransferData: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_WRITETRANSFERDATA(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_WRITETRANSFERDATA(bufferdata)[iiter]);
printf("\n");
printf("| Buffers: ");
for (iiter = 0; iiter < niter; ++iiter)
- printf("%p ", NBF_BUFFERS(bufferdata)[iiter]);
+ printf("%p ", (void *)NBF_BUFFERS(bufferdata)[iiter]);
printf("\n");
printf("|\n");
}
@@ -5974,7 +5970,7 @@ NpyIter_DebugPrint(NpyIter *iter)
}
printf("| Ptrs: ");
for (iiter = 0; iiter < niter; ++iiter) {
- printf("%p ", NAD_PTRS(axisdata)[iiter]);
+ printf("%p ", (void *)NAD_PTRS(axisdata)[iiter]);
}
printf("\n");
if (itflags&NPY_ITFLAG_HASINDEX) {
diff --git a/numpy/core/src/npymath/npy_math_complex.c.src b/numpy/core/src/npymath/npy_math_complex.c.src
index 68cfa6ea1..718de5b6c 100644
--- a/numpy/core/src/npymath/npy_math_complex.c.src
+++ b/numpy/core/src/npymath/npy_math_complex.c.src
@@ -275,10 +275,10 @@
#ifdef HAVE_@KIND@@C@
@ctype@ npy_@kind@@c@(@ctype@ x, @ctype@ y)
{
- __@ctype@_to_c99_cast x1 = {x};
- __@ctype@_to_c99_cast y1 = {y};
+ __@ctype@_to_c99_cast xcast = {x};
+ __@ctype@_to_c99_cast ycast = {y};
__@ctype@_to_c99_cast ret;
- ret.c99_z = @kind@@c@(x1.c99_z, y1.c99_z);
+ ret.c99_z = @kind@@c@(xcast.c99_z, ycast.c99_z);
return ret.npy_z;
}
#endif
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src
index 418e81531..2bcc516b1 100644
--- a/numpy/core/src/scalarmathmodule.c.src
+++ b/numpy/core/src/scalarmathmodule.c.src
@@ -1007,9 +1007,9 @@ static PyObject *
/**end repeat**/
#if defined(NPY_PY3K)
-#define NONZERO_NAME(prefix, suffix) prefix##bool##suffix
+#define NONZERO_NAME(prefix) prefix##bool
#else
-#define NONZERO_NAME(prefix, suffix) prefix##nonzero##suffix
+#define NONZERO_NAME(prefix) prefix##nonzero
#endif
#define _IS_NONZERO(x) (x != 0)
@@ -1020,7 +1020,7 @@ static PyObject *
* #nonzero=_IS_NONZERO*10, !npy_half_iszero, _IS_NONZERO*6#
*/
static int
-NONZERO_NAME(@name@_,)(PyObject *a)
+NONZERO_NAME(@name@_)(PyObject *a)
{
int ret;
npy_@name@ arg1;
@@ -1029,7 +1029,7 @@ NONZERO_NAME(@name@_,)(PyObject *a)
if (PyErr_Occurred()) {
return -1;
}
- return PyGenericArrType_Type.tp_as_number->NONZERO_NAME(nb_,)(a);
+ return PyGenericArrType_Type.tp_as_number->NONZERO_NAME(nb_)(a);
}
/*