[PATCH weston] tests: Remove the redundant NULL checks

Seedo Eldho Paul seedoeldhopaul at gmail.com
Thu Sep 3 11:47:18 PDT 2015


xzalloc is guaranteed to return a non-NULL value.

Signed-off-by: Seedo Eldho Paul <seedoeldhopaul at gmail.com>
---
 tests/internal-screenshot-test.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
index e72a695..a74ae7a 100644
--- a/tests/internal-screenshot-test.c
+++ b/tests/internal-screenshot-test.c
@@ -93,11 +93,6 @@ load_surface_from_png(const char *fname)
 
 	/* Disguise the cairo surface in a weston test surface */
 	reference = xzalloc(sizeof *reference);
-	if (reference == NULL) {
-		perror("xzalloc reference");
-		cairo_surface_destroy(reference_cairo_surface);
-		return NULL;
-	}
 	reference->width = cairo_image_surface_get_width(reference_cairo_surface);
 	reference->height = cairo_image_surface_get_height(reference_cairo_surface);
 	stride = cairo_image_surface_get_stride(reference_cairo_surface);
@@ -115,12 +110,6 @@ load_surface_from_png(const char *fname)
 	/* Allocate new buffer for our weston reference, and copy the data from
 	   the cairo surface so we can destroy it */
 	reference->data = xzalloc(source_data_size);
-	if (reference->data == NULL) {
-		perror("xzalloc reference data");
-		cairo_surface_destroy(reference_cairo_surface);
-		free(reference);
-		return NULL;
-	}
 	memcpy(reference->data,
 	       cairo_image_surface_get_data(reference_cairo_surface),
 	       source_data_size);
@@ -144,8 +133,6 @@ create_screenshot_surface(struct client *client)
 {
 	struct surface* screenshot;
 	screenshot = xzalloc(sizeof *screenshot);
-	if (screenshot == NULL)
-		return NULL;
 	screenshot->wl_buffer = create_shm_buffer(client,
 						  client->output->width,
 						  client->output->height,
-- 
1.9.1



More information about the wayland-devel mailing list