summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2013-09-16 12:45:21 +0200
committerUli Schlachter <psychon@znc.in>2013-09-16 12:59:03 +0200
commit9c75065ecefe18557c9d56e1c973215f01f3cd40 (patch)
tree69e5f0b0460942a02f66dfa591c80d3fceffb9d6
parent440624cdf2bd55ac1620e697cc481a8fbbb1c657 (diff)
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@znc.in>
-rw-r--r--src/cairo-xcb-connection-core.c32
-rw-r--r--src/cairo-xcb-connection-shm.c6
-rw-r--r--src/cairo-xcb-private.h5
-rw-r--r--src/cairo-xcb-surface.c23
4 files changed, 22 insertions, 44 deletions
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)) {