[cairo] [cairo-commit] 5 commits - src/cairo-botor-scan-converter.c src/cairo-box-inline.h src/cairo-boxes-private.h src/cairo-boxes.c src/cairo-clip-boxes.c src/cairo-line.c src/cairo-polygon-intersect.c src/cairo-polygon-reduce.c src/cairo-qt-surface.cpp

Uli Schlachter psychon at znc.in
Sat Jul 2 12:19:37 UTC 2016


Am 02.07.2016 um 14:03 schrieb Chris Wilson:
> On Sat, Jul 02, 2016 at 11:43:47AM +0000, Uli Schlachter wrote:
>> commit ae403448af410984852aeff76278dc96e7141b9e
>> Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
>> Date:   Thu Jun 30 17:45:42 2016 +0200
>>
>>     core: fix compiler warnings
>>     
>>     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.
> 
> I thought I nacked this patch.

Which of the five million times that this patch was sent to the mailing list? :-)
I must have missed that.

I tried diffing the compiler output before/after this patch, but that produced
many "weird" changes, so I cannot really say which difference this makes.

Do you want to revert this? How else could the compiler warnings be silenced?
What do you e.g. think about the following patch?

Cheers,
Uli


diff --git a/src/cairo-botor-scan-converter.c b/src/cairo-botor-scan-converter.c
index 64883a6..b2170a5 100644
--- a/src/cairo-botor-scan-converter.c
+++ b/src/cairo-botor-scan-converter.c
@@ -450,41 +450,30 @@ edges_compare_x_for_y (const cairo_edge_t *a,
      * compare events at end-points, this happens frequently enough to warrant
      * special casing).
      */
-    enum {
-       HAVE_NEITHER = 0x0,
-       HAVE_AX      = 0x1,
-       HAVE_BX      = 0x2,
-       HAVE_BOTH    = HAVE_AX | HAVE_BX
-    } have_ax_bx = HAVE_BOTH;
-    int32_t ax = 0, bx = 0;
+    int32_t *ax = NULL, *bx = NULL;

     /* XXX given we have x and dx? */

     if (y == a->line.p1.y)
-	ax = a->line.p1.x;
+	ax = &a->line.p1.x;
     else if (y == a->line.p2.y)
-	ax = a->line.p2.x;
-    else
-	have_ax_bx &= ~HAVE_AX;
+	ax = &a->line.p2.x;

     if (y == b->line.p1.y)
-	bx = b->line.p1.x;
+	bx = &b->line.p1.x;
     else if (y == b->line.p2.y)
-	bx = b->line.p2.x;
-    else
-	have_ax_bx &= ~HAVE_BX;
+	bx = &b->line.p2.x;

-    switch (have_ax_bx) {
-    default:
-    case HAVE_NEITHER:
-	return edges_compare_x_for_y_general (a, b, y);
-    case HAVE_AX:
-	return -edge_compare_for_y_against_x (b, y, ax);
-    case HAVE_BX:
-	return edge_compare_for_y_against_x (a, y, bx);
-    case HAVE_BOTH:
-	return ax - bx;
-    }
+    if (ax && bx)
+	return *ax - *bx;
+
+    if (ax)
+	return -edge_compare_for_y_against_x (b, y, *ax);
+
+    if (bx)
+	return edge_compare_for_y_against_x (a, y, *bx);
+
+    return edges_compare_x_for_y_general (a, b, y);
 }

 static inline int


-- 
"Because I'm in pain," he says. "That's the only way I get your attention."
He picks up the box. "Don't worry, Katniss. It'll pass."
He leaves before I can answer.


More information about the cairo mailing list