#include <stddef.h>
#include <stdint.h>
#include <string.h>
+#include <errno.h>
#include <limits.h>
#include <sys/types.h>
{
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
- if (bo->image != NULL)
+ if (bo->image != NULL) {
+ errno = EINVAL;
return -1;
+ }
memcpy(bo->map, buf, count);
int gbm_format;
/* Required for query image WIDTH & HEIGHT */
- if (dri->image->base.version < 4)
+ if (dri->image->base.version < 4) {
+ errno = ENOSYS;
return NULL;
+ }
switch (type) {
#if HAVE_WAYLAND_PLATFORM
{
struct wl_drm_buffer *wb;
- if (!dri->wl_drm)
+ if (!dri->wl_drm) {
+ errno = EINVAL;
return NULL;
+ }
wb = wayland_drm_buffer_get(dri->wl_drm, (struct wl_resource *) buffer);
- if (!wb)
+ if (!wb) {
+ errno = EINVAL;
return NULL;
+ }
image = dri->image->dupImage(wb->driver_buffer, NULL);
case GBM_BO_IMPORT_EGL_IMAGE:
{
int dri_format;
- if (dri->lookup_image == NULL)
+ if (dri->lookup_image == NULL) {
+ errno = EINVAL;
return NULL;
+ }
image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data);
image = dri->image->dupImage(image, NULL);
dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format);
gbm_format = gbm_dri_to_gbm_format(dri_format);
- if (gbm_format == 0)
+ if (gbm_format == 0) {
+ errno = EINVAL;
return NULL;
+ }
break;
}
}
default:
+ errno = ENOSYS;
return NULL;
}
dri_use |= __DRI_IMAGE_USE_CURSOR;
if (dri->image->base.version >= 2 &&
!dri->image->validateUsage(bo->image, dri_use)) {
+ errno = EINVAL;
free(bo);
return NULL;
}
struct drm_mode_destroy_dumb destroy_arg;
int ret;
- if (!(usage & GBM_BO_USE_CURSOR_64X64))
+ if (!(usage & GBM_BO_USE_CURSOR_64X64)) {
+ errno = EINVAL;
return NULL;
- if (format != GBM_FORMAT_ARGB8888)
+ }
+ if (format != GBM_FORMAT_ARGB8888) {
+ errno = EINVAL;
return NULL;
+ }
bo = calloc(1, sizeof *bo);
if (bo == NULL)
dri_format = __DRI_IMAGE_FORMAT_XRGB2101010;
break;
default:
+ errno = EINVAL;
goto failed;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <errno.h>
#include "gbm.h"
#include "gbmint.h"
int i;
if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
- fprintf(stderr, "_gbm_mesa_get_device: invalid fd: %d\n", fd);
+ errno = EINVAL;
return NULL;
}
struct stat buf;
if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
- fprintf(stderr, "gbm_create_device: invalid fd: %d\n", fd);
+ errno = EINVAL;
return NULL;
}
* \param bo The buffer object
* \param buf The data to write
* \param count The number of bytes to write
- * \return Returns -1 on error, 0 otherwise
+ * \return Returns 0 on success, otherwise -1 is returned an errno set
*/
GBM_EXPORT int
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count)
*
* \return A newly allocated buffer that should be freed with gbm_bo_destroy()
* when no longer needed. If an error occurs during allocation %NULL will be
- * returned.
+ * returned and errno set.
*
* \sa enum gbm_bo_format for the list of formats
* \sa enum gbm_bo_flags for the list of usage flags
uint32_t width, uint32_t height,
uint32_t format, uint32_t usage)
{
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
+ errno = EINVAL;
return NULL;
+ }
if (usage & GBM_BO_USE_CURSOR_64X64 &&
- (width != 64 || height != 64))
+ (width != 64 || height != 64)) {
+ errno = EINVAL;
return NULL;
+ }
return gbm->bo_create(gbm, width, height, format, usage);
}
* \param usage The union of the usage flags for this buffer
*
* \return A newly allocated buffer object that should be freed with
- * gbm_bo_destroy() when no longer needed.
+ * gbm_bo_destroy() when no longer needed. On error, %NULL is returned
+ * and errno is set.
*
* \sa enum gbm_bo_flags for the list of usage flags
*/