[cairo] [PATCH v8 04/71] core: fix compiler warnings

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Thu Jun 30 15:45:42 UTC 2016


The code correct, but the compiler can't check that and thinks
there're uninitialized variables.

Perhaps we could rewrite it in a better way, so the compiler
can do better (even arch specific) optimizations.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/cairo-botor-scan-converter.c | 2 +-
 src/cairo-line.c                 | 8 ++++----
 src/cairo-polygon-intersect.c    | 2 +-
 src/cairo-polygon-reduce.c       | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/cairo-botor-scan-converter.c b/src/cairo-botor-scan-converter.c
index e23aefe..64883a6 100644
--- a/src/cairo-botor-scan-converter.c
+++ b/src/cairo-botor-scan-converter.c
@@ -456,7 +456,7 @@ edges_compare_x_for_y (const cairo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     /* XXX given we have x and dx? */
 
diff --git a/src/cairo-line.c b/src/cairo-line.c
index cb13927..dc00a9c 100644
--- a/src/cairo-line.c
+++ b/src/cairo-line.c
@@ -110,9 +110,9 @@ lines_compare_x_for_y_general (const cairo_line_t *a,
      * should prevent that before the tessellation algorithm
      * begins.
      */
-    int32_t dx;
-    int32_t adx, ady;
-    int32_t bdx, bdy;
+    int32_t dx = 0;
+    int32_t adx = 0, ady = 0;
+    int32_t bdx = 0, bdy = 0;
     enum {
        HAVE_NONE    = 0x0,
        HAVE_DX      = 0x1,
@@ -218,7 +218,7 @@ lines_compare_x_for_y (const cairo_line_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->p1.y)
 	ax = a->p1.x;
diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c
index 8cb8fb1..9c1777f 100644
--- a/src/cairo-polygon-intersect.c
+++ b/src/cairo-polygon-intersect.c
@@ -447,7 +447,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->edge.line.p1.y)
 	ax = a->edge.line.p1.x;
diff --git a/src/cairo-polygon-reduce.c b/src/cairo-polygon-reduce.c
index ea457fe..da6c9ab 100644
--- a/src/cairo-polygon-reduce.c
+++ b/src/cairo-polygon-reduce.c
@@ -445,7 +445,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->edge.line.p1.y)
 	ax = a->edge.line.p1.x;
-- 
2.6.4.442.g545299f



More information about the cairo mailing list