wayland: Improve error messages during SHM buffer creation

Use g_critical rather than fprintf and and also grab the error messages from
errno and from Cairo
This commit is contained in:
Rob Bradford
2012-04-19 17:18:46 +01:00
parent d4c1b46a9e
commit b5845514ec

View File

@ -34,6 +34,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <errno.h>
#include <wayland-egl.h>
@ -442,13 +443,15 @@ create_shm_buffer (struct wl_shm *shm,
fd = mkstemp (filename);
if (fd < 0) {
fprintf(stderr, "open %s failed: %m\n", filename);
g_critical (G_STRLOC ": Unable to create temporary file (%s): %s",
filename, g_strerror (errno));
return NULL;
}
stride = width * 4;
size = stride * height;
if (ftruncate (fd, size) < 0) {
fprintf(stderr, "ftruncate failed: %m\n");
g_critical (G_STRLOC ": Truncating temporary file failed: %s",
g_strerror (errno));
close(fd);
return NULL;
}
@ -457,7 +460,8 @@ create_shm_buffer (struct wl_shm *shm,
unlink (filename);
if (data == MAP_FAILED) {
fprintf(stderr, "mmap failed: %m\n");
g_critical (G_STRLOC ": mmap'ping temporary file failed: %s",
g_strerror (errno));
close(fd);
return NULL;
}
@ -490,7 +494,8 @@ gdk_wayland_create_cairo_surface (GdkWaylandDisplay *display,
int width, int height)
{
GdkWaylandCairoSurfaceData *data;
cairo_surface_t *surface;
cairo_surface_t *surface = NULL;
cairo_status_t status;
data = g_new (GdkWaylandCairoSurfaceData, 1);
data->display = display;
@ -514,8 +519,12 @@ gdk_wayland_create_cairo_surface (GdkWaylandDisplay *display,
cairo_surface_set_user_data (surface, &gdk_wayland_cairo_key,
data, gdk_wayland_cairo_surface_destroy);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
fprintf (stderr, "create image surface failed\n");
status = cairo_surface_status (surface);
if (status != CAIRO_STATUS_SUCCESS)
{
g_critical (G_STRLOC ": Unable to create Cairo image surface: %s",
cairo_status_to_string (status));
}
return surface;
}