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 <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
@ -95,8 +96,7 @@ cogl_dma_buf_handle_free (CoglDmaBufHandle *dmabuf_handle)
|
||||
if (dmabuf_handle->destroy_func)
|
||||
g_clear_pointer (&dmabuf_handle->user_data, dmabuf_handle->destroy_func);
|
||||
|
||||
if (dmabuf_handle->dmabuf_fd != -1)
|
||||
close (dmabuf_handle->dmabuf_fd);
|
||||
g_clear_fd (&dmabuf_handle->dmabuf_fd, NULL);
|
||||
|
||||
g_free (dmabuf_handle);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <xf86drm.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
@ -343,8 +344,7 @@ destroy_dumb_buffer (MetaDrmBufferDumb *buffer_dumb)
|
||||
};
|
||||
drmIoctl (fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
|
||||
|
||||
if (buffer_dumb->dmabuf_fd != -1)
|
||||
close (buffer_dumb->dmabuf_fd);
|
||||
g_clear_fd (&buffer_dumb->dmabuf_fd, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "wayland/meta-wayland-dma-buf.h"
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -1785,10 +1786,7 @@ meta_wayland_dma_buf_buffer_finalize (GObject *object)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < META_WAYLAND_DMA_BUF_MAX_FDS; i++)
|
||||
{
|
||||
if (dma_buf->fds[i] != -1)
|
||||
close (dma_buf->fds[i]);
|
||||
}
|
||||
g_clear_fd (&dma_buf->fds[i], NULL);
|
||||
|
||||
G_OBJECT_CLASS (meta_wayland_dma_buf_buffer_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <errno.h>
|
||||
#include <glib-unix.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@ -254,11 +255,7 @@ try_display (int display,
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
close (fd);
|
||||
fd = -1;
|
||||
}
|
||||
g_clear_fd (&fd, NULL);
|
||||
}
|
||||
|
||||
*filename_out = filename;
|
||||
|
Loading…
Reference in New Issue
Block a user