lib: Port some manual close() cleanups to be glnx_fd_close

Just noticed this while reading some code, we didn't have many manual
`out: close()` bits left, this pushes us over the edge to autocleanup
almost everywhere.

Closes: #332
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2016-06-13 14:58:55 +00:00
1 parent 14ff4f94fb
commit 7847bc7394
5 files changed
+14 -44

No files matched your search

+3 -9
View File
@@ -357,7 +357,7 @@ ot_gfile_replace_contents_fsync (GFile *path,
GError **error)
{
gboolean ret = FALSE;
int parent_dfd;
glnx_fd_close int parent_dfd = -1;
const char *target_basename = glnx_basename (gs_file_get_path_cached (path));
g_autoptr(GFile) parent = NULL;
@@ -374,8 +374,6 @@ ot_gfile_replace_contents_fsync (GFile *path,
ret = TRUE;
out:
if (parent_dfd != -1)
(void) close (parent_dfd);
return ret;
}
@@ -412,7 +410,7 @@ ot_util_fsync_directory (GFile *dir,
GError **error)
{
gboolean ret = FALSE;
int dfd = -1;
glnx_fd_close int dfd = -1;
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (dir), TRUE,
&dfd, error))
@@ -426,8 +424,6 @@ ot_util_fsync_directory (GFile *dir,
ret = TRUE;
out:
if (dfd != -1)
(void) close (dfd);
return ret;
}
@@ -446,7 +442,7 @@ ot_util_ensure_directory_and_fsync (GFile *dir,
GError **error)
{
gboolean ret = FALSE;
int parentfd = -1;
glnx_fd_close int parentfd = -1;
const char *basename = glnx_basename (gs_file_get_path_cached (dir));
g_autoptr(GFile) parent = g_file_get_parent (dir);
@@ -495,7 +491,5 @@ ot_util_ensure_directory_and_fsync (GFile *dir,
ret = TRUE;
out:
if (parentfd != -1)
(void) close (parentfd);
return ret;
}