repo/checkout: Convert a few functions to new "stmt-decl/FALSE" style

Just testing the waters a bit more.  Yeah, definitely nicer.

Closes: #722
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-03-06 15:27:22 -05:00 committed by Atomic Bot
parent bb3a0e3fa4
commit 3e32d5c4b6
1 changed files with 18 additions and 25 deletions

View File

@ -947,10 +947,6 @@ ostree_repo_checkout_at (OstreeRepo *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
g_autoptr(GFile) commit_root = NULL;
g_autoptr(GFile) target_dir = NULL;
g_autoptr(GFileInfo) target_info = NULL;
OstreeRepoCheckoutAtOptions default_options = { 0, }; OstreeRepoCheckoutAtOptions default_options = { 0, };
if (!options) if (!options)
@ -959,33 +955,33 @@ ostree_repo_checkout_at (OstreeRepo *self,
options = &default_options; options = &default_options;
} }
commit_root = (GFile*) _ostree_repo_file_new_for_commit (self, commit, error); g_autoptr(GFile) commit_root = (GFile*) _ostree_repo_file_new_for_commit (self, commit, error);
if (!commit_root) if (!commit_root)
goto out; return FALSE;
if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)commit_root, error)) if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)commit_root, error))
goto out; return FALSE;
g_autoptr(GFile) target_dir = NULL;
if (options->subpath && strcmp (options->subpath, "/") != 0) if (options->subpath && strcmp (options->subpath, "/") != 0)
target_dir = g_file_get_child (commit_root, options->subpath); target_dir = g_file_get_child (commit_root, options->subpath);
else else
target_dir = g_object_ref (commit_root); target_dir = g_object_ref (commit_root);
target_info = g_file_query_info (target_dir, OSTREE_GIO_FAST_QUERYINFO, g_autoptr(GFileInfo) target_info =
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, g_file_query_info (target_dir, OSTREE_GIO_FAST_QUERYINFO,
cancellable, error); G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
if (!target_info) if (!target_info)
goto out; return FALSE;
if (!checkout_tree_at (self, options, if (!checkout_tree_at (self, options,
destination_dfd, destination_dfd,
destination_path, destination_path,
(OstreeRepoFile*)target_dir, target_info, (OstreeRepoFile*)target_dir, target_info,
cancellable, error)) cancellable, error))
goto out; return FALSE;
ret = TRUE; return TRUE;
out:
return ret;
} }
static guint static guint
@ -1039,16 +1035,15 @@ ostree_repo_checkout_gc (OstreeRepo *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
g_autoptr(GHashTable) to_clean_dirs = NULL; g_autoptr(GHashTable) to_clean_dirs = NULL;
GHashTableIter iter;
gpointer key, value;
g_mutex_lock (&self->cache_lock); g_mutex_lock (&self->cache_lock);
to_clean_dirs = self->updated_uncompressed_dirs; to_clean_dirs = self->updated_uncompressed_dirs;
self->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL); self->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL);
g_mutex_unlock (&self->cache_lock); g_mutex_unlock (&self->cache_lock);
GHashTableIter iter;
gpointer key, value;
if (to_clean_dirs) if (to_clean_dirs)
g_hash_table_iter_init (&iter, to_clean_dirs); g_hash_table_iter_init (&iter, to_clean_dirs);
while (to_clean_dirs && g_hash_table_iter_next (&iter, &key, &value)) while (to_clean_dirs && g_hash_table_iter_next (&iter, &key, &value))
@ -1058,7 +1053,7 @@ ostree_repo_checkout_gc (OstreeRepo *self,
if (!glnx_dirfd_iterator_init_at (self->uncompressed_objects_dir_fd, objdir_name, FALSE, if (!glnx_dirfd_iterator_init_at (self->uncompressed_objects_dir_fd, objdir_name, FALSE,
&dfd_iter, error)) &dfd_iter, error))
goto out; return FALSE;
while (TRUE) while (TRUE)
{ {
@ -1066,14 +1061,14 @@ ostree_repo_checkout_gc (OstreeRepo *self,
struct stat stbuf; struct stat stbuf;
if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
goto out; return FALSE;
if (dent == NULL) if (dent == NULL)
break; break;
if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
{ {
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
goto out; return FALSE;
} }
if (stbuf.st_nlink == 1) if (stbuf.st_nlink == 1)
@ -1081,13 +1076,11 @@ ostree_repo_checkout_gc (OstreeRepo *self,
if (unlinkat (dfd_iter.fd, dent->d_name, 0) != 0) if (unlinkat (dfd_iter.fd, dent->d_name, 0) != 0)
{ {
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
goto out; return FALSE;
} }
} }
} }
} }
ret = TRUE; return TRUE;
out:
return ret;
} }