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:
1 parent
14ff4f94fb
commit
7847bc7394
5 files changed
+14
-44
No files matched your search
@@ -172,8 +172,8 @@ copy_dir_recurse (int src_parent_dfd,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int src_dfd = -1;
|
||||
int dest_dfd = -1;
|
||||
glnx_fd_close int src_dfd = -1;
|
||||
glnx_fd_close int dest_dfd = -1;
|
||||
DIR *srcd = NULL;
|
||||
struct dirent *dent;
|
||||
|
||||
@@ -240,10 +240,6 @@ copy_dir_recurse (int src_parent_dfd,
|
||||
/* Note the srcd owns src_dfd */
|
||||
src_dfd = -1;
|
||||
}
|
||||
if (src_dfd != -1)
|
||||
(void) close (src_dfd);
|
||||
if (dest_dfd != -1)
|
||||
(void) close (dest_dfd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -257,8 +253,8 @@ ensure_directory_from_template (int orig_etc_fd,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int src_dfd = -1;
|
||||
int target_dfd = -1;
|
||||
glnx_fd_close int src_dfd = -1;
|
||||
glnx_fd_close int target_dfd = -1;
|
||||
|
||||
g_assert (path != NULL);
|
||||
g_assert (*path != '/' && *path != '\0');
|
||||
@@ -316,10 +312,6 @@ ensure_directory_from_template (int orig_etc_fd,
|
||||
target_dfd = -1;
|
||||
}
|
||||
out:
|
||||
if (src_dfd != -1)
|
||||
(void) close (src_dfd);
|
||||
if (target_dfd != -1)
|
||||
(void) close (target_dfd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -341,7 +333,7 @@ copy_modified_config_file (int orig_etc_fd,
|
||||
gboolean ret = FALSE;
|
||||
struct stat modified_stbuf;
|
||||
struct stat new_stbuf;
|
||||
int dest_parent_dfd = -1;
|
||||
glnx_fd_close int dest_parent_dfd = -1;
|
||||
|
||||
if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0)
|
||||
{
|
||||
@@ -431,8 +423,6 @@ copy_modified_config_file (int orig_etc_fd,
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (dest_parent_dfd != -1)
|
||||
(void) close (dest_parent_dfd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -459,9 +449,9 @@ merge_etc_changes (GFile *orig_etc,
|
||||
g_autoptr(GPtrArray) removed = NULL;
|
||||
g_autoptr(GPtrArray) added = NULL;
|
||||
guint i;
|
||||
int orig_etc_fd = -1;
|
||||
int modified_etc_fd = -1;
|
||||
int new_etc_fd = -1;
|
||||
glnx_fd_close int orig_etc_fd = -1;
|
||||
glnx_fd_close int modified_etc_fd = -1;
|
||||
glnx_fd_close int new_etc_fd = -1;
|
||||
|
||||
modified = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_diff_item_unref);
|
||||
removed = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||
@@ -538,12 +528,6 @@ merge_etc_changes (GFile *orig_etc,
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (orig_etc_fd != -1)
|
||||
(void) close (orig_etc_fd);
|
||||
if (modified_etc_fd != -1)
|
||||
(void) close (modified_etc_fd);
|
||||
if (new_etc_fd != -1)
|
||||
(void) close (new_etc_fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user