mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
Use g_clear_fd() instead of open coding the same behavior
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2806>
This commit is contained in:
parent
f34c6da956
commit
49b0a8921c
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <linux/dma-buf.h>
|
#include <linux/dma-buf.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -95,8 +96,7 @@ cogl_dma_buf_handle_free (CoglDmaBufHandle *dmabuf_handle)
|
|||||||
if (dmabuf_handle->destroy_func)
|
if (dmabuf_handle->destroy_func)
|
||||||
g_clear_pointer (&dmabuf_handle->user_data, dmabuf_handle->destroy_func);
|
g_clear_pointer (&dmabuf_handle->user_data, dmabuf_handle->destroy_func);
|
||||||
|
|
||||||
if (dmabuf_handle->dmabuf_fd != -1)
|
g_clear_fd (&dmabuf_handle->dmabuf_fd, NULL);
|
||||||
close (dmabuf_handle->dmabuf_fd);
|
|
||||||
|
|
||||||
g_free (dmabuf_handle);
|
g_free (dmabuf_handle);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -343,8 +344,7 @@ destroy_dumb_buffer (MetaDrmBufferDumb *buffer_dumb)
|
|||||||
};
|
};
|
||||||
drmIoctl (fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
|
drmIoctl (fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
|
||||||
|
|
||||||
if (buffer_dumb->dmabuf_fd != -1)
|
g_clear_fd (&buffer_dumb->dmabuf_fd, NULL);
|
||||||
close (buffer_dumb->dmabuf_fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "wayland/meta-wayland-dma-buf.h"
|
#include "wayland/meta-wayland-dma-buf.h"
|
||||||
|
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -1785,10 +1786,7 @@ meta_wayland_dma_buf_buffer_finalize (GObject *object)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < META_WAYLAND_DMA_BUF_MAX_FDS; i++)
|
for (i = 0; i < META_WAYLAND_DMA_BUF_MAX_FDS; i++)
|
||||||
{
|
g_clear_fd (&dma_buf->fds[i], NULL);
|
||||||
if (dma_buf->fds[i] != -1)
|
|
||||||
close (dma_buf->fds[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_wayland_dma_buf_buffer_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_wayland_dma_buf_buffer_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -254,11 +255,7 @@ try_display (int display,
|
|||||||
g_free (filename);
|
g_free (filename);
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
|
|
||||||
if (fd >= 0)
|
g_clear_fd (&fd, NULL);
|
||||||
{
|
|
||||||
close (fd);
|
|
||||||
fd = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*filename_out = filename;
|
*filename_out = filename;
|
||||||
|
Loading…
Reference in New Issue
Block a user