[cairo-commit] 5 commits - configure.ac src/cairo-image-surface.c src/cairo-xcb-connection-core.c src/cairo-xcb-connection-shm.c src/cairo-xcb-private.h src/cairo-xcb-surface.c src/check-doc-syntax.awk src/check-doc-syntax.sh test/multi-page.c

Uli Schlachter psychon at kemper.freedesktop.org
Mon Sep 16 04:00:09 PDT 2013


 configure.ac                    |    2 +-
 src/cairo-image-surface.c       |    3 +++
 src/cairo-xcb-connection-core.c |   32 ++++++++++----------------------
 src/cairo-xcb-connection-shm.c  |    6 ++----
 src/cairo-xcb-private.h         |    5 ++---
 src/cairo-xcb-surface.c         |   23 ++++++++---------------
 src/check-doc-syntax.awk        |    2 --
 src/check-doc-syntax.sh         |    2 +-
 test/multi-page.c               |    4 ++--
 9 files changed, 29 insertions(+), 50 deletions(-)

New commits:
commit 9c75065ecefe18557c9d56e1c973215f01f3cd40
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Sep 16 12:45:21 2013 +0200

    xcb: Remove useless error handling
    
    All the *_reply() functions in XCB return a pointer to their result and as last
    argument they get a xcb_generic_error_t** where pointers to errors are stored,
    if any occurs.
    
    However, a request can either fail or succeed. This means that if the returned
    result is a NULL pointer, then an error occurred and the other way around: If
    the error pointer is set to non-NULL, then the function must have returned NULL.
    
    Thus, all the code, which just checks if an error occurred and which does not
    care about the exact error code, does not need to get the error pointer at all.
    In this case, xcb will free() the error internally.
    
    While doing this, I noticed that _cairo_xcb_connection_get_image() always
    succeeds and thus its return value can be replaced with the GetImage result.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection-core.c b/src/cairo-xcb-connection-core.c
index ae7c023..386297d 100644
--- a/src/cairo-xcb-connection-core.c
+++ b/src/cairo-xcb-connection-core.c
@@ -283,32 +283,20 @@ _cairo_xcb_connection_put_subimage (cairo_xcb_connection_t *connection,
     }
 }
 
-cairo_status_t
+xcb_get_image_reply_t *
 _cairo_xcb_connection_get_image (cairo_xcb_connection_t *connection,
 				 xcb_drawable_t src,
 				 int16_t src_x,
 				 int16_t src_y,
 				 uint16_t width,
-				 uint16_t height,
-				 xcb_get_image_reply_t **reply)
+				 uint16_t height)
 {
-    xcb_generic_error_t *error;
-
-    *reply = xcb_get_image_reply (connection->xcb_connection,
-				  xcb_get_image (connection->xcb_connection,
-						 XCB_IMAGE_FORMAT_Z_PIXMAP,
-						 src,
-						 src_x, src_y,
-						 width, height,
-						 (uint32_t) -1),
-
-				  &error);
-    if (error) {
-	free (error);
-
-	free (*reply);
-	*reply = NULL;
-    }
-
-    return CAIRO_STATUS_SUCCESS;
+    return xcb_get_image_reply (connection->xcb_connection,
+				xcb_get_image (connection->xcb_connection,
+					       XCB_IMAGE_FORMAT_Z_PIXMAP,
+					       src,
+					       src_x, src_y,
+					       width, height,
+					       (uint32_t) -1),
+				NULL);
 }
diff --git a/src/cairo-xcb-connection-shm.c b/src/cairo-xcb-connection-shm.c
index 8c1d506..7720bbb 100644
--- a/src/cairo-xcb-connection-shm.c
+++ b/src/cairo-xcb-connection-shm.c
@@ -82,7 +82,6 @@ _cairo_xcb_connection_shm_get_image (cairo_xcb_connection_t *connection,
 				     uint32_t offset)
 {
     xcb_shm_get_image_reply_t *reply;
-    xcb_generic_error_t *error;
 
     assert (connection->flags & CAIRO_XCB_HAS_SHM);
     reply = xcb_shm_get_image_reply (connection->xcb_connection,
@@ -93,12 +92,11 @@ _cairo_xcb_connection_shm_get_image (cairo_xcb_connection_t *connection,
 							(uint32_t) -1,
 							XCB_IMAGE_FORMAT_Z_PIXMAP,
 							shmseg, offset),
-				     &error);
+				     NULL);
     free (reply);
 
-    if (error) {
+    if (!reply) {
 	/* an error here should be impossible */
-	free (error);
 	return _cairo_error (CAIRO_STATUS_READ_ERROR);
     }
 
diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index f6cb34e..5f04803 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -505,14 +505,13 @@ _cairo_xcb_connection_put_subimage (cairo_xcb_connection_t *connection,
 				    uint8_t depth,
 				    void *data);
 
-cairo_private cairo_status_t
+cairo_private xcb_get_image_reply_t *
 _cairo_xcb_connection_get_image (cairo_xcb_connection_t *connection,
 				 xcb_drawable_t src,
 				 int16_t src_x,
 				 int16_t src_y,
 				 uint16_t width,
-				 uint16_t height,
-				 xcb_get_image_reply_t **reply);
+				 uint16_t height);
 
 cairo_private void
 _cairo_xcb_connection_poly_fill_rectangle (cairo_xcb_connection_t *connection,
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 746fb45..c900edc 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -382,13 +382,10 @@ _get_image (cairo_xcb_surface_t		 *surface,
 	}
     }
 
-    status = _cairo_xcb_connection_get_image (connection,
-					      surface->drawable,
-					      x, y,
-					      width, height,
-					      &reply);
-    if (unlikely (status))
-	goto FAIL;
+    reply =_cairo_xcb_connection_get_image (connection,
+					    surface->drawable,
+					    x, y,
+					    width, height);
 
     if (reply == NULL && ! surface->owns_pixmap) {
 	/* xcb_get_image_t from a window is dangerous because it can
@@ -422,15 +419,11 @@ _get_image (cairo_xcb_surface_t		 *surface,
 
 	_cairo_xcb_screen_put_gc (surface->screen, surface->depth, gc);
 
-	status = _cairo_xcb_connection_get_image (connection,
-						  pixmap,
-						  0, 0,
-						  width, height,
-						  &reply);
+	reply = _cairo_xcb_connection_get_image (connection,
+						 pixmap,
+						 0, 0,
+						 width, height);
 	_cairo_xcb_connection_free_pixmap (connection, pixmap);
-
-	if (unlikely (status))
-	    goto FAIL;
     }
 
     if (unlikely (reply == NULL)) {
commit 440624cdf2bd55ac1620e697cc481a8fbbb1c657
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Sep 15 15:00:02 2013 +0200

    test/multi-page: Fix use-after-free
    
    Commit f9dcd07d22a5269 changed the way the file name is allocated and introduced
    a use-after-free in doing so.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/test/multi-page.c b/test/multi-page.c
index e5b3dd2..e2c7ddf 100644
--- a/test/multi-page.c
+++ b/test/multi-page.c
@@ -157,9 +157,9 @@ preamble (cairo_test_context_t *ctx)
 	draw_some_pages (surface);
 
 	cairo_surface_destroy (surface);
-	free (filename);
 
 	printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
+	free (filename);
     }
 #endif
 
@@ -181,9 +181,9 @@ preamble (cairo_test_context_t *ctx)
 	draw_some_pages (surface);
 
 	cairo_surface_destroy (surface);
-	free (filename);
 
 	printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
+	free (filename);
     }
 #endif
 
commit 1d00550784d052e9b72b3c91d5769f771033037c
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Sep 15 14:50:20 2013 +0200

    image: Handle PIXMAN_a8r8g8b8_sRGB in switch
    
    Fixes the following compiler warning:
    
    cairo-image-surface.c: In function '_cairo_format_from_pixman_format':
    cairo-image-surface.c:93: warning: enumeration value 'PIXMAN_a8r8g8b8_sRGB' not
    handled in switch
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58726
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 824dbf3..e42cc7d 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -107,6 +107,9 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format)
 #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)
     case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8:
 #endif
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,27,2)
+    case PIXMAN_a8r8g8b8_sRGB:
+#endif
     case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8:
     case PIXMAN_b8g8r8:   case PIXMAN_b5g6r5:
     case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5:
commit 966bf2fe6a8c29f4d10b20f982a4ab198a441c78
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Sep 15 16:58:05 2013 +0200

    check-doc-syntax: Don't hardcode path to awk
    
    Instead of expecting awk in /usr/bin, this commit changes the code to call awk
    through a shell so that $PATH is searched.
    
    Since this awk script shouldn't really be called manually, this is done by
    removing the shebang from the awk script, marking it non-executable and fixing
    up the caller.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67674
    Reviewed-by: Bryce Harrington <b.harrington at samsung.com>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/check-doc-syntax.awk b/src/check-doc-syntax.awk
old mode 100755
new mode 100644
index 5fdabda..1fa8b8d
--- a/src/check-doc-syntax.awk
+++ b/src/check-doc-syntax.awk
@@ -1,5 +1,3 @@
-#!/usr/bin/awk -f
-
 BEGIN {
     name_found = 1
     SECTION_DOC = 0
diff --git a/src/check-doc-syntax.sh b/src/check-doc-syntax.sh
index c74fb87..762a484 100755
--- a/src/check-doc-syntax.sh
+++ b/src/check-doc-syntax.sh
@@ -72,7 +72,7 @@ fi >&2
 
 # Only run the syntax checker on the source files (not doc/)
 if test -e ./check-doc-syntax.awk; then
-    if echo $FILES | xargs ./check-doc-syntax.awk ; then
+    if echo $FILES | xargs awk -f ./check-doc-syntax.awk ; then
 	    :
     else
 	    stat=1
commit a8a805b8d9bbbfed9986ecc71e76859a5353730f
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Sep 13 22:18:08 2013 +0200

    cairo-gobject: Require at least glib 2.14
    
    cairo-gobject uses g_once_init_enter() and g_once_init_leave(). These functions
    were added in glib 2.14 and thus cairo needs at least this version for its
    gobject helper functions.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69239
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/configure.ac b/configure.ac
index c5ed33b..959ae36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -704,7 +704,7 @@ dnl ===========================================================================
 dnl Build gobject integration library
 
 CAIRO_ENABLE_FUNCTIONS(gobject, gobject, auto, [
-  gobject_REQUIRES="gobject-2.0 glib-2.0"
+  gobject_REQUIRES="gobject-2.0 glib-2.0 >= 2.14"
   PKG_CHECK_MODULES(GOBJECT, $gobject_REQUIRES, ,
     [use_gobject="no (requires $gobject_REQUIRES http://download.gnome.org/pub/GNOME/sources/glib/)"])
   gobject_NONPKGCONFIG_EXTRA_LIBS="-L\${libdir} -lcairo-gobject"


More information about the cairo-commit mailing list