Mostly for the latest `-Wmaybe-uninitialized` fix, but while here also port some
places to newer APIs.
Update submodule: libglnx
Closes: #1027
Approved by: jlebon
-Subproject commit 607f1775bb1c626cae1875a957a34802daebe81c
+Subproject commit ea6df95f22c8f2973714bdbb8b1accc4e37d4d56
}
/* Now let's fdatasync() for the new file */
- { glnx_fd_close int new_config_fd = open (gs_file_get_path_cached (new_config_path), O_RDONLY | O_CLOEXEC);
- if (new_config_fd < 0)
- {
- glnx_set_prefix_error_from_errno (error, "Opening %s", gs_file_get_path_cached (new_config_path));
- goto out;
- }
+ { glnx_fd_close int new_config_fd = -1;
+ if (!glnx_openat_rdonly (AT_FDCWD, gs_file_get_path_cached (new_config_path), TRUE, &new_config_fd, error))
+ goto out;
+
if (fdatasync (new_config_fd) < 0)
{
- glnx_set_error_from_errno (error);
+ (void)glnx_throw_errno_prefix (error, "fdatasync");
goto out;
}
}
GCancellable *cancellable,
GError **error)
{
- int glnx_fd_close fd = openat (parent_dfd, path, O_RDONLY | O_CLOEXEC);
- if (fd < 0)
- return glnx_throw_errno_prefix (error, "open(%s)", path);
+ glnx_fd_close int fd = -1;
+ if (!glnx_openat_rdonly (parent_dfd, path, TRUE, &fd, error))
+ return FALSE;
struct stat stbuf;
if (!glnx_fstat (fd, &stbuf, error))
glnx_fd_close int fd = -1;
ot_auto_gpgme_data gpgme_data_t kdata = NULL;
- fd = openat (AT_FDCWD, path, O_RDONLY | O_CLOEXEC) ;
- if (fd < 0)
- {
- glnx_set_prefix_error_from_errno (error, "Opening %s", path);
- goto out;
- }
+ if (!glnx_openat_rdonly (AT_FDCWD, path, TRUE, &fd, error))
+ goto out;
gpg_error = gpgme_data_new_from_fd (&kdata, fd);
if (gpg_error != GPG_ERR_NO_ERROR)
while (TRUE)
{
struct dirent *dent;
- struct stat stbuf;
- g_autoptr(GFileInfo) child_info = NULL;
- const char *loose_checksum;
if (!glnx_dirfd_iterator_next_dent (src_dfd_iter, &dent, cancellable, error))
return FALSE;
if (dent == NULL)
break;
- if (fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) == -1)
- return glnx_throw_errno (error);
+ struct stat stbuf;
+ if (!glnx_fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
+ return FALSE;
- loose_checksum = devino_cache_lookup (self, modifier, stbuf.st_dev, stbuf.st_ino);
+ const char *loose_checksum = devino_cache_lookup (self, modifier, stbuf.st_dev, stbuf.st_ino);
if (loose_checksum)
{
if (!ostree_mutable_tree_replace_file (mtree, dent->d_name, loose_checksum,
continue;
}
- child_info = _ostree_stbuf_to_gfileinfo (&stbuf);
+ g_autoptr(GFileInfo) child_info = _ostree_stbuf_to_gfileinfo (&stbuf);
g_file_info_set_name (child_info, dent->d_name);
if (S_ISREG (stbuf.st_mode))
if (objtype == OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT)
goto out;
- fd = openat (_ostree_fetcher_get_dfd (fetcher), tmp_unlinker.path, O_RDONLY | O_CLOEXEC);
- if (fd == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (!glnx_openat_rdonly (_ostree_fetcher_get_dfd (fetcher), tmp_unlinker.path, TRUE, &fd, error))
+ goto out;
/* Now delete it, keeping the fd open as the last reference; see comment in
* corresponding content fetch path.
if (!_ostree_fetcher_request_to_tmpfile_finish (fetcher, result, &temp_path, error))
goto out;
- fd = openat (_ostree_fetcher_get_dfd (fetcher), temp_path, O_RDONLY | O_CLOEXEC);
- if (fd == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (!glnx_openat_rdonly (_ostree_fetcher_get_dfd (fetcher), temp_path, TRUE, &fd, error))
+ goto out;
/* From here on, if we fail to apply the delta, we'll re-fetch it */
if (unlinkat (_ostree_fetcher_get_dfd (fetcher), temp_path, 0) < 0)
return FALSE;
g_autofree char *superblock = _ostree_get_relative_static_delta_superblock_path ((from && from[0]) ? from : NULL, to);
- glnx_fd_close int superblock_file_fd = openat (self->repo_dir_fd, superblock, O_RDONLY | O_CLOEXEC);
- if (superblock_file_fd == -1)
- return glnx_throw_errno (error);
+ glnx_fd_close int superblock_file_fd = -1;
+
+ if (!glnx_openat_rdonly (self->repo_dir_fd, superblock, TRUE, &superblock_file_fd, error))
+ return FALSE;
g_autoptr(GInputStream) in_stream = g_unix_input_stream_new (superblock_file_fd, FALSE);
if (!in_stream)
if (dent == NULL)
break;
- if (fstatat (src_dfd_iter.fd, dent->d_name, &child_stbuf,
- AT_SYMLINK_NOFOLLOW) != 0)
- return glnx_throw_errno (error);
+ if (!glnx_fstatat (src_dfd_iter.fd, dent->d_name, &child_stbuf,
+ AT_SYMLINK_NOFOLLOW, error))
+ return FALSE;
if (S_ISDIR (child_stbuf.st_mode))
{