summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2010-06-30 12:41:11 +0100
committerBrian Paul <brianp@vmware.com>2010-06-30 07:59:39 -0600
commita6392e991580c081b26b28be5c20795d6090283f (patch)
tree7df82975554e8b7ac71ef2de7cf7d48ef7488f11
parentc73b73ee3328da74bbe74c7ea65e52b9d4e469a3 (diff)
downloadglu-a6392e991580c081b26b28be5c20795d6090283f.tar.gz
glu: Fix some compiler warnings in libtess
When compiled with the more aggressive compiler warnings such as -Wshadow and -Wempty-body the libtess code gives a lot more warnings. This fixes the following issues: * The 'Swap' macro tries to combine multiple statements into one and then consume the trailing semicolon by using if(1){/*...*/}else. This gives warnings because the else part ends up with an empty statement. It also seems a bit dangerous because if the semicolon were missed then it would still be valid syntax but it would just ignore the following statement. This patch replaces it with the more common idiom do { /*...*/ } while(0). * 'free' was being used as a local variable name but this shadows the global function. This has been renamed to 'free_handle' * TRUE and FALSE were being unconditionally defined. Although this isn't currently a problem it seems better to guard them with #ifndef because it's quite common for them to be defined in other headers. https://bugs.freedesktop.org/show_bug.cgi?id=28845 Signed-off-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/libtess/geom.c2
-rw-r--r--src/libtess/mesh.c4
-rw-r--r--src/libtess/normal.c4
-rw-r--r--src/libtess/priorityq-heap.c22
-rw-r--r--src/libtess/priorityq.c2
-rw-r--r--src/libtess/render.c8
-rw-r--r--src/libtess/sweep.c4
-rw-r--r--src/libtess/tess.c4
8 files changed, 37 insertions, 13 deletions
diff --git a/src/libtess/geom.c b/src/libtess/geom.c
index 7d3b8d8..35b36a3 100644
--- a/src/libtess/geom.c
+++ b/src/libtess/geom.c
@@ -198,7 +198,7 @@ printf("*********************%d\n",RandomInterpolate);
#endif
-#define Swap(a,b) if (1) { GLUvertex *t = a; a = b; b = t; } else
+#define Swap(a,b) do { GLUvertex *t = a; a = b; b = t; } while (0)
void __gl_edgeIntersect( GLUvertex *o1, GLUvertex *d1,
GLUvertex *o2, GLUvertex *d2,
diff --git a/src/libtess/mesh.c b/src/libtess/mesh.c
index 95f87cd..36cb3a7 100644
--- a/src/libtess/mesh.c
+++ b/src/libtess/mesh.c
@@ -38,8 +38,12 @@
#include "mesh.h"
#include "memalloc.h"
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
static GLUvertex *allocVertex()
{
diff --git a/src/libtess/normal.c b/src/libtess/normal.c
index 7ab8316..9a3bd43 100644
--- a/src/libtess/normal.c
+++ b/src/libtess/normal.c
@@ -39,8 +39,12 @@
#include <math.h>
#include <assert.h>
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
#define Dot(u,v) (u[0]*v[0] + u[1]*v[1] + u[2]*v[2])
diff --git a/src/libtess/priorityq-heap.c b/src/libtess/priorityq-heap.c
index e3a6c60..52698b5 100644
--- a/src/libtess/priorityq-heap.c
+++ b/src/libtess/priorityq-heap.c
@@ -39,8 +39,12 @@
#define INIT_SIZE 32
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
#ifdef FOR_TRITE_TEST_PROGRAM
#define LEQ(x,y) (*pq->leq)(x,y)
@@ -159,7 +163,7 @@ void pqInit( PriorityQ *pq )
PQhandle pqInsert( PriorityQ *pq, PQkey keyNew )
{
long curr;
- PQhandle free;
+ PQhandle free_handle;
curr = ++ pq->size;
if( (curr*2) > pq->max ) {
@@ -186,21 +190,21 @@ PQhandle pqInsert( PriorityQ *pq, PQkey keyNew )
}
if( pq->freeList == 0 ) {
- free = curr;
+ free_handle = curr;
} else {
- free = pq->freeList;
- pq->freeList = pq->handles[free].node;
+ free_handle = pq->freeList;
+ pq->freeList = pq->handles[free_handle].node;
}
- pq->nodes[curr].handle = free;
- pq->handles[free].node = curr;
- pq->handles[free].key = keyNew;
+ pq->nodes[curr].handle = free_handle;
+ pq->handles[free_handle].node = curr;
+ pq->handles[free_handle].key = keyNew;
if( pq->initialized ) {
FloatUp( pq, curr );
}
- assert(free != LONG_MAX);
- return free;
+ assert(free_handle != LONG_MAX);
+ return free_handle;
}
/* really __gl_pqHeapExtractMin */
diff --git a/src/libtess/priorityq.c b/src/libtess/priorityq.c
index 11f0263..c6b99cc 100644
--- a/src/libtess/priorityq.c
+++ b/src/libtess/priorityq.c
@@ -85,7 +85,7 @@ void pqDeletePriorityQ( PriorityQ *pq )
#define LT(x,y) (! LEQ(y,x))
#define GT(x,y) (! LEQ(x,y))
-#define Swap(a,b) if(1){PQkey *tmp = *a; *a = *b; *b = tmp;}else
+#define Swap(a,b) do{PQkey *tmp = *a; *a = *b; *b = tmp;}while(0)
/* really __gl_pqSortInit */
int pqInit( PriorityQ *pq )
diff --git a/src/libtess/render.c b/src/libtess/render.c
index 4f376f7..bca836f 100644
--- a/src/libtess/render.c
+++ b/src/libtess/render.c
@@ -39,8 +39,12 @@
#include "tess.h"
#include "render.h"
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
/* This structure remembers the information we need about a primitive
* to be able to render it later, once we have determined which
@@ -143,11 +147,11 @@ static void RenderMaximumFaceGroup( GLUtesselator *tess, GLUface *fOrig )
#define AddToTrail(f,t) ((f)->trail = (t), (t) = (f), (f)->marked = TRUE)
-#define FreeTrail(t) if( 1 ) { \
+#define FreeTrail(t) do { \
while( (t) != NULL ) { \
(t)->marked = FALSE; t = (t)->trail; \
} \
- } else /* absorb trailing semicolon */
+ } while(0) /* absorb trailing semicolon */
diff --git a/src/libtess/sweep.c b/src/libtess/sweep.c
index 744be6b..eca828f 100644
--- a/src/libtess/sweep.c
+++ b/src/libtess/sweep.c
@@ -46,8 +46,12 @@
#include "memalloc.h"
#include "sweep.h"
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
#ifdef FOR_TRITE_TEST_PROGRAM
extern void DebugEvent( GLUtesselator *tess );
diff --git a/src/libtess/tess.c b/src/libtess/tess.c
index 029a02c..4a0e8de 100644
--- a/src/libtess/tess.c
+++ b/src/libtess/tess.c
@@ -47,8 +47,12 @@
#define GLU_TESS_DEFAULT_TOLERANCE 0.0
#define GLU_TESS_MESH 100112 /* void (*)(GLUmesh *mesh) */
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
/*ARGSUSED*/ static void GLAPIENTRY noBegin( GLenum type ) {}
/*ARGSUSED*/ static void GLAPIENTRY noEdgeFlag( GLboolean boundaryEdge ) {}