kmssink: Fixup all errno tracing

All DRM ioctl uses errno to report the error and simply returns -1
when some error occured. This patch fixes all usage of the return
value instead of errno to trace the error type and moves to g_strerror
instead of string.h strerror in order to be consistent with the rest
of GStreamer.
This commit is contained in:
Nicolas Dufresne 2019-05-26 12:13:48 +02:00
parent 85c389df24
commit 112baf404e
2 changed files with 18 additions and 20 deletions

View file

@ -31,7 +31,6 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
@ -132,7 +131,8 @@ gst_kms_allocator_memory_reset (GstKMSAllocator * allocator, GstKMSMemory * mem)
err = drmIoctl (allocator->priv->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
if (err)
GST_WARNING_OBJECT (allocator,
"Failed to destroy dumb buffer object: %s %d", strerror (errno), errno);
"Failed to destroy dumb buffer object: %s %d",
g_strerror (errno), errno);
g_free (mem->bo);
mem->bo = NULL;
@ -240,7 +240,7 @@ done:
create_failed:
{
GST_ERROR_OBJECT (allocator, "Failed to create buffer object: %s (%d)",
strerror (-ret), ret);
g_strerror (errno), errno);
g_free (kmsmem->bo);
kmsmem->bo = NULL;
return FALSE;
@ -367,7 +367,7 @@ gst_kms_memory_map (GstMemory * mem, gsize maxsize, GstMapFlags flags)
err = drmIoctl (alloc->priv->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
if (err) {
GST_ERROR_OBJECT (alloc, "Failed to get offset of buffer object: %s %d",
strerror (-err), err);
g_strerror (errno), errno);
return NULL;
}
@ -375,7 +375,7 @@ gst_kms_memory_map (GstMemory * mem, gsize maxsize, GstMapFlags flags)
PROT_READ | PROT_WRITE, MAP_SHARED, alloc->priv->fd, arg.offset);
if (out == MAP_FAILED) {
GST_ERROR_OBJECT (alloc, "Failed to map dumb buffer object: %s %d",
strerror (errno), errno);
g_strerror (errno), errno);
return NULL;
}
kmsmem->bo->ptr = out;
@ -469,7 +469,7 @@ gst_kms_allocator_add_fb (GstKMSAllocator * alloc, GstKMSMemory * kmsmem,
offsets, &kmsmem->fb_id, 0);
if (ret) {
GST_ERROR_OBJECT (alloc, "Failed to bind to framebuffer: %s (%d)",
strerror (-ret), ret);
g_strerror (errno), errno);
return FALSE;
}
@ -547,7 +547,7 @@ gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds,
err = drmIoctl (alloc->priv->fd, DRM_IOCTL_GEM_CLOSE, &arg);
if (err)
GST_WARNING_OBJECT (allocator,
"Failed to close GEM handle: %s %d", strerror (errno), errno);
"Failed to close GEM handle: %s %d", g_strerror (errno), errno);
kmsmem->gem_handle[i] = 0;
}
@ -558,7 +558,7 @@ gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds,
import_fd_failed:
{
GST_ERROR_OBJECT (alloc, "Failed to import prime fd %d: %s (%d)",
prime_fds[i], strerror (-ret), ret);
prime_fds[i], g_strerror (errno), errno);
/* fallback */
}

View file

@ -56,8 +56,6 @@
#include <xf86drmMode.h>
#include <drm_fourcc.h>
#include <string.h>
#include "gstkmssink.h"
#include "gstkmsutils.h"
#include "gstkmsbufferpool.h"
@ -491,7 +489,7 @@ mode_failed:
}
modesetting_failed:
{
GST_ERROR_OBJECT (self, "Failed to set mode: %s", strerror (errno));
GST_ERROR_OBJECT (self, "Failed to set mode: %s", g_strerror (errno));
goto bail;
}
}
@ -833,7 +831,7 @@ open_failed:
{
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ_WRITE,
("Could not open DRM module %s", GST_STR_NULL (self->devname)),
("reason: %s (%d)", strerror (errno), errno));
("reason: %s (%d)", g_strerror (errno), errno));
return FALSE;
}
@ -841,7 +839,7 @@ resources_failed:
{
GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
("drmModeGetResources failed"),
("reason: %s (%d)", strerror (errno), errno));
("reason: %s (%d)", g_strerror (errno), errno));
goto bail;
}
@ -870,7 +868,7 @@ plane_resources_failed:
{
GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
("drmModeGetPlaneResources failed"),
("reason: %s (%d)", strerror (errno), errno));
("reason: %s (%d)", g_strerror (errno), errno));
goto bail;
}
@ -1324,20 +1322,20 @@ gst_kms_sink_sync (GstKMSSink * self)
/* ERRORS */
vblank_failed:
{
GST_WARNING_OBJECT (self, "drmWaitVBlank failed: %s (%d)", strerror (-ret),
ret);
GST_WARNING_OBJECT (self, "drmWaitVBlank failed: %s (%d)",
g_strerror (errno), errno);
return FALSE;
}
pageflip_failed:
{
GST_WARNING_OBJECT (self, "drmModePageFlip failed: %s (%d)",
strerror (-ret), ret);
g_strerror (errno), errno);
return FALSE;
}
event_failed:
{
GST_ERROR_OBJECT (self, "drmHandleEvent failed: %s (%d)", strerror (-ret),
ret);
GST_ERROR_OBJECT (self, "drmHandleEvent failed: %s (%d)",
g_strerror (errno), errno);
return FALSE;
}
}
@ -1667,7 +1665,7 @@ set_plane_failed:
result.w, result.h, src.x, src.y, src.w, src.h, dst.x, dst.y, dst.w,
dst.h);
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
(NULL), ("drmModeSetPlane failed: %s (%d)", strerror (-ret), ret));
(NULL), ("drmModeSetPlane failed: %s (%d)", g_strerror (errno), errno));
goto bail;
}
no_disp_ratio: