[PATCH] Fix "warning: XXX may be used uninitialized in this function"

Tomas Carnecky tom at dbservice.com
Wed Feb 4 11:18:38 PST 2009


These are all false-positives so I choose to initialize
the variables at declaration time.

Xext/xtest.c:
I assumed that the 'switch(type)' handles all possible cases,
though it probably would be better to add a default case with
assert(0), FatalError() or similar.

mi/miarc.c:
'dashRemaining' is set and used only inside 'if (isDashed)' blocks.

mi/mizerarc.c:
'oddPts' is set when 'pGC->lineStyle != LineSolid' but is later
only used when 'pGC->lineStyle == LineDoubleDash'.

glx/indirect_texture_compression.c:
I assumed that CALL_GetTexLevelParameteriv() does not overwrite
compsize in case an error occurs.

Signed-off-by: Tomas Carnecky <tom at dbservice.com>
---
 Xext/xtest.c                       |    2 +-
 glx/indirect_texture_compression.c |    4 ++--
 mi/miarc.c                         |    2 +-
 mi/mizerarc.c                      |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Xext/xtest.c b/Xext/xtest.c
index 7e95c86..3b05ef0 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -156,7 +156,7 @@ ProcXTestFakeInput(ClientPtr client)
     int numValuators = 0;
     int firstValuator = 0;
     EventListPtr events;
-    int nevents;
+    int nevents = 0;
     int i;
     int base = 0;
 
diff --git a/glx/indirect_texture_compression.c b/glx/indirect_texture_compression.c
index 25c6eb3..5f44d7b 100644
--- a/glx/indirect_texture_compression.c
+++ b/glx/indirect_texture_compression.c
@@ -52,7 +52,7 @@ int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *p
 	const GLenum target = *(GLenum *)(pc + 0);
 	const GLint  level  = *(GLint  *)(pc + 4);
 	GLint compsize = 0;
-	char *answer, answerBuffer[200];
+	char *answer = NULL, answerBuffer[200];
 
 	CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
 
@@ -92,7 +92,7 @@ int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyt
 	const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) );
 	const GLint  level =  (GLint ) bswap_32( *(int *)(pc + 4) );
 	GLint compsize = 0;
-	char *answer, answerBuffer[200];
+	char *answer = NULL, answerBuffer[200];
 
 	CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
 
diff --git a/mi/miarc.c b/mi/miarc.c
index 12c360c..a3e2580 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -1884,7 +1884,7 @@ miComputeArcs (
 	int		arcsJoin;
 	int		selfJoin;
 
-	int		iDash = 0, dashRemaining;
+	int		iDash = 0, dashRemaining = 0;
 	int		iDashStart = 0, dashRemainingStart = 0, iphaseStart;
 	int		startAngle, spanAngle, endAngle, backwards = 0;
 	int		prevDashAngle, dashAngle;
diff --git a/mi/mizerarc.c b/mi/mizerarc.c
index 9c8df34..ad84c01 100644
--- a/mi/mizerarc.c
+++ b/mi/mizerarc.c
@@ -709,7 +709,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
     int n, maxw = 0;
     xArc *arc;
     int i;
-    DDXPointPtr points, pts, oddPts;
+    DDXPointPtr points, pts, oddPts = NULL;
     DDXPointPtr pt;
     int numPts;
     Bool dospans;
-- 
1.6.1.2





More information about the xorg mailing list