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
@@ -2558,7 +2558,7 @@ load_metadata_internal (OstreeRepo *self,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
|
||||
int fd = -1;
|
||||
glnx_fd_close int fd = -1;
|
||||
g_autoptr(GInputStream) ret_stream = NULL;
|
||||
g_autoptr(GVariant) ret_variant = NULL;
|
||||
|
||||
@@ -2586,8 +2586,6 @@ load_metadata_internal (OstreeRepo *self,
|
||||
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
|
||||
if (!mfile)
|
||||
goto out;
|
||||
(void) close (fd); /* Ignore errors, we have it mapped */
|
||||
fd = -1;
|
||||
ret_variant = g_variant_new_from_data (ostree_metadata_variant_type (objtype),
|
||||
g_mapped_file_get_contents (mfile),
|
||||
g_mapped_file_get_length (mfile),
|
||||
@@ -2632,8 +2630,6 @@ load_metadata_internal (OstreeRepo *self,
|
||||
ot_transfer_out_value (out_variant, &ret_variant);
|
||||
ot_transfer_out_value (out_stream, &ret_stream);
|
||||
out:
|
||||
if (fd != -1)
|
||||
(void) close (fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user