Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f97b8c

Browse files
committed
Fix compiler warnings.
svn path=/trunk/matplotlib/; revision=8364
1 parent 07c0dc8 commit 0f97b8c

5 files changed

Lines changed: 45 additions & 44 deletions

File tree

lib/matplotlib/delaunay/_delaunay.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ using namespace std;
1212

1313
extern "C" {
1414

15-
static void reorder_edges(int npoints, int ntriangles,
16-
double *x, double *y,
15+
static void reorder_edges(int npoints, int ntriangles,
16+
double *x, double *y,
1717
int *edge_db, int *tri_edges, int *tri_nbrs)
1818
{
1919
int neighbors[3], nodes[3];
@@ -69,7 +69,7 @@ static void reorder_edges(int npoints, int ntriangles,
6969

7070
// Not trusting me? Okay, let's go through it:
7171
// We have three edges to deal with and three nodes. Without loss
72-
// of generality, let's label the nodes A, B, and C with (A, B)
72+
// of generality, let's label the nodes A, B, and C with (A, B)
7373
// forming the first edge in the order they arrive on input.
7474
// Then there are eight possibilities as to how the other edge-tuples
7575
// may be labeled, but only two variations that are going to affect the
@@ -85,7 +85,7 @@ static void reorder_edges(int npoints, int ntriangles,
8585
// The second test we need to perform is for counter-clockwiseness.
8686
// Again, there are only two variations that will affect the outcome:
8787
// either ABC is counter-clockwise, or it isn't. In the former case,
88-
// we're done setting the node order, we just need to associate the
88+
// we're done setting the node order, we just need to associate the
8989
// appropriate neighbor triangles with their opposite nodes, something
9090
// which can be done by inspection. In the latter case, to order the
9191
// nodes counter-clockwise, we only have to switch B and C to get
@@ -113,7 +113,7 @@ static void reorder_edges(int npoints, int ntriangles,
113113

114114
static PyObject* getMesh(int npoints, double *x, double *y)
115115
{
116-
PyObject *vertices, *edge_db, *tri_edges, *tri_nbrs;
116+
PyObject *vertices = NULL, *edge_db = NULL, *tri_edges = NULL, *tri_nbrs = NULL;
117117
PyObject *temp;
118118
int tri0, tri1, reg0, reg1;
119119
double tri0x, tri0y, tri1x, tri1y;
@@ -138,7 +138,7 @@ static PyObject* getMesh(int npoints, double *x, double *y)
138138
edge_db = PyArray_SimpleNew(2, dim, PyArray_INT);
139139
if (!edge_db) goto fail;
140140
edge_db_ptr = (int*)PyArray_DATA(edge_db);
141-
141+
142142
dim[0] = numtri;
143143
vertices = PyArray_SimpleNew(2, dim, PyArray_DOUBLE);
144144
if (!vertices) goto fail;
@@ -192,7 +192,7 @@ static PyObject* getMesh(int npoints, double *x, double *y)
192192
// tri_edges contains lists of edges; convert to lists of nodes in
193193
// counterclockwise order and reorder tri_nbrs to match. Each node
194194
// corresponds to the edge opposite it in the triangle.
195-
reorder_edges(npoints, numtri, x, y, edge_db_ptr, tri_edges_ptr,
195+
reorder_edges(npoints, numtri, x, y, edge_db_ptr, tri_edges_ptr,
196196
tri_nbrs_ptr);
197197

198198
temp = Py_BuildValue("(OOOO)", vertices, edge_db, tri_edges, tri_nbrs);
@@ -221,7 +221,7 @@ static PyObject *linear_planes(int ntriangles, double *x, double *y, double *z,
221221
int i;
222222
double *planes_ptr;
223223
double x02, y02, z02, x12, y12, z12, xy0212;
224-
224+
225225
dims[0] = ntriangles;
226226
dims[1] = 3;
227227
planes = PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
@@ -240,40 +240,40 @@ static PyObject *linear_planes(int ntriangles, double *x, double *y, double *z,
240240
xy0212 = y02/y12;
241241
INDEX3(planes_ptr,i,0) = (z02 - z12 * xy0212) / (x02 - x12 * xy0212);
242242
INDEX3(planes_ptr,i,1) = (z12 - INDEX3(planes_ptr,i,0)*x12) / y12;
243-
INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] -
244-
INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] -
243+
INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] -
244+
INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] -
245245
INDEX3(planes_ptr,i,1)*y[INDEX3(nodes,i,2)]);
246246
} else {
247247
xy0212 = x02/x12;
248248
INDEX3(planes_ptr,i,1) = (z02 - z12 * xy0212) / (y02 - y12 * xy0212);
249249
INDEX3(planes_ptr,i,0) = (z12 - INDEX3(planes_ptr,i,1)*y12) / x12;
250-
INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] -
251-
INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] -
250+
INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] -
251+
INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] -
252252
INDEX3(planes_ptr,i,1)*y[INDEX3(nodes,i,2)]);
253253
}
254254
}
255255

256256
return (PyObject*)planes;
257257
}
258258

259-
static double linear_interpolate_single(double targetx, double targety,
259+
static double linear_interpolate_single(double targetx, double targety,
260260
double *x, double *y, int *nodes, int *neighbors,
261261
PyObject *planes, double defvalue, int start_triangle, int *end_triangle)
262262
{
263263
double *planes_ptr;
264264
planes_ptr = (double*)PyArray_DATA(planes);
265265
if (start_triangle == -1) start_triangle = 0;
266-
*end_triangle = walking_triangles(start_triangle, targetx, targety,
266+
*end_triangle = walking_triangles(start_triangle, targetx, targety,
267267
x, y, nodes, neighbors);
268268
if (*end_triangle == -1) return defvalue;
269-
return (targetx*INDEX3(planes_ptr,*end_triangle,0) +
269+
return (targetx*INDEX3(planes_ptr,*end_triangle,0) +
270270
targety*INDEX3(planes_ptr,*end_triangle,1) +
271271
INDEX3(planes_ptr,*end_triangle,2));
272272
}
273273

274-
static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps,
274+
static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps,
275275
double y0, double y1, int ysteps,
276-
PyObject *planes, double defvalue,
276+
PyObject *planes, double defvalue,
277277
int npoints, double *x, double *y, int *nodes, int *neighbors)
278278
{
279279
int ix, iy;
@@ -312,7 +312,7 @@ static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps,
312312
static PyObject *compute_planes_method(PyObject *self, PyObject *args)
313313
{
314314
PyObject *pyx, *pyy, *pyz, *pynodes;
315-
PyObject *x, *y, *z, *nodes;
315+
PyObject *x = NULL, *y = NULL, *z = NULL, *nodes = NULL;
316316
int npoints, ntriangles;
317317

318318
PyObject *planes;
@@ -351,7 +351,7 @@ static PyObject *compute_planes_method(PyObject *self, PyObject *args)
351351
goto fail;
352352
}
353353

354-
planes = linear_planes(ntriangles, (double*)PyArray_DATA(x),
354+
planes = linear_planes(ntriangles, (double*)PyArray_DATA(x),
355355
(double*)PyArray_DATA(y), (double*)PyArray_DATA(z), (int*)PyArray_DATA(nodes));
356356

357357
Py_DECREF(x);
@@ -374,7 +374,7 @@ static PyObject *linear_interpolate_method(PyObject *self, PyObject *args)
374374
double x0, x1, y0, y1, defvalue;
375375
int xsteps, ysteps;
376376
PyObject *pyplanes, *pyx, *pyy, *pynodes, *pyneighbors, *grid;
377-
PyObject *planes, *x, *y, *nodes, *neighbors;
377+
PyObject *planes = NULL, *x = NULL, *y = NULL, *nodes = NULL, *neighbors = NULL;
378378
int npoints;
379379

380380

@@ -417,7 +417,7 @@ static PyObject *linear_interpolate_method(PyObject *self, PyObject *args)
417417
(PyObject*)planes, defvalue, npoints,
418418
(double*)PyArray_DATA(x), (double*)PyArray_DATA(y),
419419
(int*)PyArray_DATA(nodes), (int*)PyArray_DATA(neighbors));
420-
420+
421421
Py_DECREF(x);
422422
Py_DECREF(y);
423423
Py_DECREF(planes);
@@ -455,7 +455,7 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar
455455
{
456456
PyObject *pyx, *pyy, *pyz, *pycenters, *pynodes, *pyneighbors, *pyintx, *pyinty;
457457
PyObject *x = NULL, *y = NULL, *z = NULL, *centers = NULL, *nodes = NULL,
458-
*neighbors = NULL, *intx = NULL, *inty = NULL, *intz;
458+
*neighbors = NULL, *intx = NULL, *inty = NULL, *intz = NULL;
459459
double defvalue;
460460
int size, npoints, ntriangles;
461461

@@ -506,7 +506,7 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar
506506
return NULL;
507507
}
508508
ntriangles = PyArray_DIM(neighbors, 0);
509-
if ((PyArray_DIM(nodes, 0) != ntriangles) ||
509+
if ((PyArray_DIM(nodes, 0) != ntriangles) ||
510510
(PyArray_DIM(centers, 0) != ntriangles)) {
511511
PyErr_SetString(PyExc_ValueError, "centers,nodes,neighbors must be of equal length");
512512
CLEANUP
@@ -542,13 +542,13 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar
542542
return NULL;
543543
}
544544

545-
NaturalNeighbors nn(npoints, ntriangles,
545+
NaturalNeighbors nn(npoints, ntriangles,
546546
(double*)PyArray_DATA(x), (double*)PyArray_DATA(y),
547-
(double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes),
547+
(double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes),
548548
(int*)PyArray_DATA(neighbors));
549549
size = PyArray_Size(intx);
550-
nn.interpolate_unstructured((double*)PyArray_DATA(z), size,
551-
(double*)PyArray_DATA(intx), (double*)PyArray_DATA(inty),
550+
nn.interpolate_unstructured((double*)PyArray_DATA(z), size,
551+
(double*)PyArray_DATA(intx), (double*)PyArray_DATA(inty),
552552
(double*)PyArray_DATA(intz), defvalue);
553553

554554
Py_XDECREF(x);
@@ -575,13 +575,13 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar
575575
static PyObject *nn_interpolate_method(PyObject *self, PyObject *args)
576576
{
577577
PyObject *pyx, *pyy, *pyz, *pycenters, *pynodes, *pyneighbors, *grid;
578-
PyObject *x, *y, *z, *centers, *nodes, *neighbors;
578+
PyObject *x = NULL, *y = NULL, *z = NULL, *centers = NULL, *nodes = NULL, *neighbors = NULL;
579579
double x0, x1, y0, y1, defvalue;
580580
int xsteps, ysteps;
581581
int npoints, ntriangles;
582582
intp dims[2];
583583

584-
if (!PyArg_ParseTuple(args, "ddiddidOOOOOO", &x0, &x1, &xsteps,
584+
if (!PyArg_ParseTuple(args, "ddiddidOOOOOO", &x0, &x1, &xsteps,
585585
&y0, &y1, &ysteps, &defvalue, &pyx, &pyy, &pyz, &pycenters, &pynodes,
586586
&pyneighbors)) {
587587
return NULL;
@@ -629,7 +629,7 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args)
629629
return NULL;
630630
}
631631
ntriangles = PyArray_DIM(neighbors, 0);
632-
if ((PyArray_DIM(nodes, 0) != ntriangles) ||
632+
if ((PyArray_DIM(nodes, 0) != ntriangles) ||
633633
(PyArray_DIM(centers, 0) != ntriangles)) {
634634
PyErr_SetString(PyExc_ValueError, "centers,nodes,neighbors must be of equal length");
635635
CLEANUP
@@ -644,11 +644,11 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args)
644644
return NULL;
645645
}
646646

647-
NaturalNeighbors nn(npoints, ntriangles,
647+
NaturalNeighbors nn(npoints, ntriangles,
648648
(double*)PyArray_DATA(x), (double*)PyArray_DATA(y),
649-
(double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes),
649+
(double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes),
650650
(int*)PyArray_DATA(neighbors));
651-
nn.interpolate_grid((double*)PyArray_DATA(z),
651+
nn.interpolate_grid((double*)PyArray_DATA(z),
652652
x0, x1, xsteps,
653653
y0, y1, ysteps,
654654
(double*)PyArray_DATA(grid),
@@ -664,7 +664,7 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args)
664664
static PyObject *delaunay_method(PyObject *self, PyObject *args)
665665
{
666666
PyObject *pyx, *pyy, *mesh;
667-
PyObject *x, *y;
667+
PyObject *x = NULL, *y = NULL;
668668
int npoints;
669669

670670
if (!PyArg_ParseTuple(args, "OO", &pyx, &pyy)) {
@@ -703,7 +703,7 @@ static PyObject *delaunay_method(PyObject *self, PyObject *args)
703703
}
704704

705705
static PyMethodDef delaunay_methods[] = {
706-
{"delaunay", (PyCFunction)delaunay_method, METH_VARARGS,
706+
{"delaunay", (PyCFunction)delaunay_method, METH_VARARGS,
707707
"Compute the Delaunay triangulation of a cloud of 2-D points.\n\n"
708708
"circumcenters, edges, tri_points, tri_neighbors = delaunay(x, y)\n\n"
709709
"x, y -- shape-(npoints,) arrays of floats giving the X and Y coordinates of the points\n"
@@ -730,7 +730,7 @@ static PyMethodDef delaunay_methods[] = {
730730
PyMODINIT_FUNC init_delaunay(void)
731731
{
732732
PyObject* m;
733-
m = Py_InitModule3("_delaunay", delaunay_methods,
733+
m = Py_InitModule3("_delaunay", delaunay_methods,
734734
"Tools for computing the Delaunay triangulation and some operations on it.\n"
735735
);
736736
if (m == NULL)

lib/matplotlib/tri/_tri.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,8 @@ void
990990
#endif
991991
init_tri()
992992
{
993-
static TriModule* triModule = new TriModule;
993+
static TriModule* triModule = NULL;
994+
triModule = new TriModule();
994995
import_array();
995996
}
996997

src/_path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ void clip_to_rect(PathIterator& path,
818818
}
819819

820820
Polygon polygon1, polygon2;
821-
double x, y;
821+
double x = 0, y = 0;
822822
unsigned code = 0;
823823
path.rewind(0);
824824

src/cntr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ edge_walker (Csite * site, int pass2)
607607
}
608608
if (fwd < 0 && level0 && left < 0)
609609
{
610-
/* remove J0_START from this boundary edge as boundary is
611-
* included by the upwards slit from contour line below. */
610+
/* remove J0_START from this boundary edge as boundary is
611+
* included by the upwards slit from contour line below. */
612612
data[edge] &= ~J0_START;
613613
if (n_kind) kcp[n_kind] += kind_start_slit;
614614
return slit_cutter (site, 0, pass2);
@@ -1479,8 +1479,8 @@ build_cntr_list_v2(long *np, double *xp, double *yp, short *kp,
14791479
int nparts, long ntotal)
14801480
{
14811481
PyObject *all_contours;
1482-
PyArrayObject *xyv;
1483-
PyArrayObject *kv;
1482+
PyArrayObject *xyv = NULL;
1483+
PyArrayObject *kv = NULL;
14841484
npy_intp dims[2];
14851485
npy_intp kdims[1];
14861486
int i;

src/path_converters.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ class PathNanRemover : protected EmbeddedQueue<4> {
233233
} while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
234234
return agg::path_cmd_move_to;
235235
}
236-
}
237236

238-
return code;
237+
return code;
238+
}
239239
}
240240
};
241241

0 commit comments

Comments
 (0)