diff options
author | Colin Walters <walters@verbum.org> | 2017-10-16 14:09:39 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-10-16 18:06:53 -0400 |
commit | 771d7a01d1104bbb8240cb29393314c7a4a69c4d (patch) | |
tree | aac733372fe9e87fdcae2379be38a5087716f941 /glnx-fdio.c | |
parent | e627524af9ae499c1edd04795442f8bdb05b5223 (diff) | |
download | libglnx-771d7a01d1104bbb8240cb29393314c7a4a69c4d.tar.gz |
tree-wide: Use glnx_autofd and glnx_close_fd()
Port to `glnx_autofd` tree wide, and add one missed `glnx_close_fd()` use in the
tmpfile code.
Diffstat (limited to 'glnx-fdio.c')
-rw-r--r-- | glnx-fdio.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c index 892be2a..b24d03f 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -175,11 +175,7 @@ glnx_tmpfile_clear (GLnxTmpfile *tmpf) return; if (!tmpf->initialized) return; - if (tmpf->fd != -1) - { - if (close (tmpf->fd) < 0) - g_assert (errno != EBADF); - } + glnx_close_fd (&tmpf->fd); /* If ->path is set, we're likely aborting due to an error. Clean it up */ if (tmpf->path) { @@ -196,7 +192,7 @@ open_tmpfile_core (int dfd, const char *subpath, GError **error) { const guint mode = 0600; - glnx_fd_close int fd = -1; + glnx_autofd int fd = -1; int count; dfd = glnx_dirfd_canonicalize (dfd); @@ -576,7 +572,7 @@ glnx_file_get_contents_utf8_at (int dfd, { dfd = glnx_dirfd_canonicalize (dfd); - glnx_fd_close int fd = -1; + glnx_autofd int fd = -1; if (!glnx_openat_rdonly (dfd, subpath, TRUE, &fd, error)) return NULL; @@ -933,7 +929,7 @@ glnx_file_copy_at (int src_dfd, /* Regular file path below here */ - glnx_fd_close int src_fd = -1; + glnx_autofd int src_fd = -1; if (!glnx_openat_rdonly (src_dfd, src_subpath, FALSE, &src_fd, error)) return FALSE; |