tree-wide: Use g_autoptr(Ostree*)

Part of cleaning up our usage of libglnx; we want to use what's in GLib where we
can.

Had to change a few .c files to `#include ostree.h` early on to pick up
autoptrs for the core types.

Closes: #1040
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-08-03 13:48:12 +00:00
1 parent aa63d0e0c5
commit b929b620ae
47 files changed
+114 -110

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ struct _OstreeBootloaderInterface
GError **error);
gboolean (* is_atomic) (OstreeBootloader *self);
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBootloader, g_object_unref)
GType _ostree_bootloader_get_type (void) G_GNUC_CONST;
+2 -1
View File
@@ -20,6 +20,7 @@
#include "config.h"
#include "ostree.h"
#include "ostree-deployment-private.h"
#include "libglnx.h"
@@ -138,7 +139,7 @@ _ostree_deployment_set_bootcsum (OstreeDeployment *self,
OstreeDeployment *
ostree_deployment_clone (OstreeDeployment *self)
{
glnx_unref_object OstreeBootconfigParser *new_bootconfig = NULL;
g_autoptr(OstreeBootconfigParser) new_bootconfig = NULL;
OstreeDeployment *ret = ostree_deployment_new (self->index, self->osname, self->csum,
self->deployserial,
self->bootcsum, self->bootserial);
+1 -1
View File
@@ -350,7 +350,7 @@ session_thread_set_tls_interaction_cb (ThreadClosure *thread_closure,
const char *cert_and_key_path = data; /* str\0str\0 in one malloc buf */
const char *cert_path = cert_and_key_path;
const char *key_path = cert_and_key_path + strlen (cert_and_key_path) + 1;
glnx_unref_object OstreeTlsCertInteraction *interaction = NULL;
g_autoptr(OstreeTlsCertInteraction) interaction = NULL;
/* The GTlsInteraction instance must be created in the
* session thread so it uses the correct GMainContext. */
+1
View File
@@ -40,6 +40,7 @@ struct OstreeMetalinkClass
{
GObjectClass parent_class;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMetalink, g_object_unref)
GType _ostree_metalink_get_type (void) G_GNUC_CONST;
+4 -5
View File
@@ -22,9 +22,8 @@
#include "config.h"
#include "ostree-mutable-tree.h"
#include "ostree.h"
#include "otutil.h"
#include "ostree-core.h"
/**
* SECTION:ostree-mutable-tree
@@ -183,7 +182,7 @@ ostree_mutable_tree_ensure_dir (OstreeMutableTree *self,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object OstreeMutableTree *ret_dir = NULL;
g_autoptr(OstreeMutableTree) ret_dir = NULL;
g_return_val_if_fail (name != NULL, FALSE);
@@ -219,7 +218,7 @@ ostree_mutable_tree_lookup (OstreeMutableTree *self,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object OstreeMutableTree *ret_subdir = NULL;
g_autoptr(OstreeMutableTree) ret_subdir = NULL;
g_autofree char *ret_file_checksum = NULL;
ret_subdir = ot_gobject_refz (g_hash_table_lookup (self->subdirs, name));
@@ -261,7 +260,7 @@ ostree_mutable_tree_ensure_parent_dirs (OstreeMutableTree *self,
gboolean ret = FALSE;
int i;
OstreeMutableTree *subdir = self; /* nofree */
glnx_unref_object OstreeMutableTree *ret_parent = NULL;
g_autoptr(OstreeMutableTree) ret_parent = NULL;
g_assert (metadata_checksum != NULL);
+5 -5
View File
@@ -27,16 +27,16 @@
#include <gio/gfiledescriptorbased.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include "otutil.h"
#include <sys/xattr.h>
#include <glib/gprintf.h>
#include "ostree.h"
#include "ostree-core-private.h"
#include "ostree-repo-private.h"
#include "ostree-repo-file-enumerator.h"
#include "ostree-checksum-input-stream.h"
#include "ostree-mutable-tree.h"
#include "ostree-varint.h"
#include <sys/xattr.h>
#include <glib/gprintf.h>
#include "otutil.h"
gboolean
_ostree_repo_ensure_loose_objdir_at (int dfd,
@@ -2555,7 +2555,7 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
{
g_autoptr(GFile) child = NULL;
g_autoptr(GFileInfo) modified_info = NULL;
glnx_unref_object OstreeMutableTree *child_mtree = NULL;
g_autoptr(OstreeMutableTree) child_mtree = NULL;
g_autofree char *child_relpath = NULL;
const char *name;
GFileType file_type;
+7 -8
View File
@@ -22,10 +22,9 @@
#include "config.h"
#include "ostree.h"
#include "ostree-core-private.h"
#include "ostree-repo-private.h"
#include "ostree-repo-file.h"
#include "ostree-mutable-tree.h"
#ifdef HAVE_LIBARCHIVE
#include <archive.h>
@@ -185,7 +184,7 @@ mtree_ensure_dir_with_meta (OstreeRepo *repo,
GCancellable *cancellable,
GError **error)
{
glnx_unref_object OstreeMutableTree *dir = NULL;
g_autoptr(OstreeMutableTree) dir = NULL;
g_autofree guchar *csum_raw = NULL;
g_autofree char *csum = NULL;
@@ -374,7 +373,7 @@ aic_create_parent_dirs (OstreeRepoArchiveImportContext *ctx,
GError **error)
{
g_autofree char *fullpath = NULL;
glnx_unref_object OstreeMutableTree *dir = NULL;
g_autoptr(OstreeMutableTree) dir = NULL;
/* start with the root itself */
if (!aic_ensure_parent_dir (ctx, ctx->root, "/", &dir, cancellable, error))
@@ -643,7 +642,7 @@ aic_import_entry (OstreeRepoArchiveImportContext *ctx,
GError **error)
{
g_autoptr(GFileInfo) fi = NULL;
glnx_unref_object OstreeMutableTree *parent = NULL;
g_autoptr(OstreeMutableTree) parent = NULL;
g_autofree char *path = aic_get_final_entry_pathname (ctx, error);
if (path == NULL)
@@ -669,7 +668,7 @@ aic_import_from_hardlink (OstreeRepoArchiveImportContext *ctx,
const char *name = glnx_basename (target);
const char *name_dh = glnx_basename (dh->path);
g_autoptr(GPtrArray) components = NULL;
glnx_unref_object OstreeMutableTree *parent = NULL;
g_autoptr(OstreeMutableTree) parent = NULL;
if (!ostree_mutable_tree_lookup (dh->parent, name_dh, &csum, NULL, error))
return FALSE;
@@ -696,8 +695,8 @@ aic_lookup_file_csum (OstreeRepoArchiveImportContext *ctx,
{
g_autofree char *csum = NULL;
const char *name = glnx_basename (target);
glnx_unref_object OstreeMutableTree *parent = NULL;
glnx_unref_object OstreeMutableTree *subdir = NULL;
g_autoptr(OstreeMutableTree) parent = NULL;
g_autoptr(OstreeMutableTree) subdir = NULL;
g_autoptr(GPtrArray) components = NULL;
if (!ot_util_path_split_validate (target, &components, error))
+7 -7
View File
@@ -1418,7 +1418,7 @@ gpg_verify_unwritten_commit (OtPullData *pull_data,
{
if (pull_data->gpg_verify)
{
glnx_unref_object OstreeGpgVerifyResult *result = NULL;
g_autoptr(OstreeGpgVerifyResult) result = NULL;
g_autoptr(GBytes) signed_data = g_variant_get_data_as_bytes (commit);
if (!detached_metadata)
@@ -1624,7 +1624,7 @@ scan_commit_object (OtPullData *pull_data,
if (pull_data->gpg_verify)
{
glnx_unref_object OstreeGpgVerifyResult *result = NULL;
g_autoptr(OstreeGpgVerifyResult) result = NULL;
result = ostree_repo_verify_commit_for_remote (pull_data->repo,
checksum,
@@ -2748,7 +2748,7 @@ _ostree_preload_metadata_file (OstreeRepo *self,
if (is_metalink)
{
glnx_unref_object OstreeMetalink *metalink = NULL;
g_autoptr(OstreeMetalink) metalink = NULL;
GError *local_error = NULL;
/* the metalink uri is buried in the mirrorlist as the first (and only)
@@ -2898,7 +2898,7 @@ repo_remote_fetch_summary (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
glnx_unref_object OstreeFetcher *fetcher = NULL;
g_autoptr(OstreeFetcher) fetcher = NULL;
g_autoptr(GMainContext) mainctx = NULL;
gboolean ret = FALSE;
gboolean from_cache = FALSE;
@@ -3213,7 +3213,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_autoptr(GHashTable) requested_refs_to_fetch = NULL; /* (element-type OstreeCollectionRef utf8) */
g_autoptr(GHashTable) commits_to_fetch = NULL;
g_autofree char *remote_mode_str = NULL;
glnx_unref_object OstreeMetalink *metalink = NULL;
g_autoptr(OstreeMetalink) metalink = NULL;
OtPullData pull_data_real = { 0, };
OtPullData *pull_data = &pull_data_real;
GKeyFile *remote_config = NULL;
@@ -4960,7 +4960,7 @@ find_remotes_cb (GObject *obj,
&error))
goto error;
glnx_unref_object OstreeGpgVerifyResult *verify_result = NULL;
g_autoptr(OstreeGpgVerifyResult) verify_result = NULL;
verify_result = ostree_repo_verify_commit_for_remote (self,
commit_metadata->checksum,
@@ -5608,7 +5608,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self,
/* Verify any summary signatures. */
if (gpg_verify_summary && summary != NULL && signatures != NULL)
{
glnx_unref_object OstreeGpgVerifyResult *result = NULL;
g_autoptr(OstreeGpgVerifyResult) result = NULL;
result = ostree_repo_verify_summary (self,
name,
+3 -3
View File
@@ -4082,7 +4082,7 @@ ostree_repo_sign_commit (OstreeRepo *self,
* check if the commit has already been signed with the given key ID.
* We want to avoid storing duplicate signatures in the metadata. */
g_autoptr(GError) local_error = NULL;
glnx_unref_object OstreeGpgVerifyResult *result
g_autoptr(OstreeGpgVerifyResult) result
=_ostree_repo_gpg_verify_with_metadata (self, commit_data, old_metadata,
NULL, NULL, NULL,
cancellable, &local_error);
@@ -4239,7 +4239,7 @@ _ostree_repo_gpg_verify_data_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
glnx_unref_object OstreeGpgVerifier *verifier = NULL;
g_autoptr(OstreeGpgVerifier) verifier = NULL;
gboolean add_global_keyring_dir = TRUE;
verifier = _ostree_gpg_verifier_new ();
@@ -4441,7 +4441,7 @@ ostree_repo_verify_commit (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
glnx_unref_object OstreeGpgVerifyResult *result = NULL;
g_autoptr(OstreeGpgVerifyResult) result = NULL;
result = ostree_repo_verify_commit_ext (self, commit_checksum,
keyringdir, extra_keyring,
+9 -8
View File
@@ -32,6 +32,7 @@
#include <systemd/sd-journal.h>
#endif
#include "ostree.h"
#include "ostree-sysroot-private.h"
#include "ostree-sepolicy-private.h"
#include "ostree-deployment-private.h"
@@ -722,7 +723,7 @@ merge_configuration (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error)
{
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
g_autoptr(OstreeSePolicy) sepolicy = NULL;
if (previous_deployment)
{
@@ -1587,7 +1588,7 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
gboolean bootloader_is_atomic = FALSE;
gboolean boot_was_ro_mount = FALSE;
SyncStats syncstats = { 0, };
glnx_unref_object OstreeBootloader *bootloader = NULL;
g_autoptr(OstreeBootloader) bootloader = NULL;
g_assert (self->loaded);
@@ -1671,7 +1672,7 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
{
int new_bootversion = self->bootversion ? 0 : 1;
g_autofree char* new_loader_entries_dir = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(OstreeRepo) repo = NULL;
gboolean show_osname = FALSE;
if (self->booted_deployment)
@@ -1918,7 +1919,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
return FALSE;
OstreeRepo *repo = ostree_sysroot_repo (self);
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
g_autoptr(OstreeDeployment) merge_deployment = NULL;
if (provided_merge_deployment != NULL)
merge_deployment = g_object_ref (provided_merge_deployment);
@@ -1928,7 +1929,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
return FALSE;
g_autofree char *new_bootcsum = NULL;
glnx_unref_object OstreeDeployment *new_deployment =
g_autoptr(OstreeDeployment) new_deployment =
ostree_deployment_new (0, osname, revision, new_deployserial,
new_bootcsum, -1);
ostree_deployment_set_origin (new_deployment, origin);
@@ -1966,10 +1967,10 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
/* Create an empty boot configuration; we will merge things into
* it as we go.
*/
glnx_unref_object OstreeBootconfigParser *bootconfig = ostree_bootconfig_parser_new ();
g_autoptr(OstreeBootconfigParser) bootconfig = ostree_bootconfig_parser_new ();
ostree_deployment_set_bootconfig (new_deployment, bootconfig);
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
g_autoptr(OstreeSePolicy) sepolicy = NULL;
if (!merge_configuration (self, repo, merge_deployment, new_deployment,
deployment_dfd,
&sepolicy,
@@ -2047,7 +2048,7 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
{
guint i;
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
glnx_unref_object OstreeDeployment *new_deployment = NULL;
g_autoptr(OstreeDeployment) new_deployment = NULL;
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
g_autofree char *new_options = NULL;
OstreeBootconfigParser *new_bootconfig;
+11 -10
View File
@@ -25,6 +25,7 @@
#include <sys/mount.h>
#include <sys/wait.h>
#include "ostree.h"
#include "ostree-core-private.h"
#include "ostree-repo-private.h"
#include "ostree-sepolicy-private.h"
@@ -307,7 +308,7 @@ ostree_sysroot_ensure_initialized (OstreeSysroot *self,
else
{
g_autoptr(GFile) repo_dir = g_file_resolve_relative_path (self->path, "ostree/repo");
glnx_unref_object OstreeRepo *repo = ostree_repo_new (repo_dir);
g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_dir);
if (!ostree_repo_create (repo, OSTREE_REPO_MODE_BARE,
cancellable, error))
return FALSE;
@@ -454,7 +455,7 @@ _ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
g_str_has_suffix (dent->d_name, ".conf") &&
S_ISREG (stbuf.st_mode))
{
glnx_unref_object OstreeBootconfigParser *config = ostree_bootconfig_parser_new ();
g_autoptr(OstreeBootconfigParser) config = ostree_bootconfig_parser_new ();
if (!ostree_bootconfig_parser_parse_at (config, dfd_iter.fd, dent->d_name, cancellable, error))
return glnx_prefix_error (error, "Parsing %s", dent->d_name);
@@ -624,7 +625,7 @@ parse_deployment (OstreeSysroot *self,
cancellable, error))
return FALSE;
glnx_unref_object OstreeDeployment *ret_deployment
g_autoptr(OstreeDeployment) ret_deployment
= ostree_deployment_new (-1, osname, treecsum, deployserial,
bootcsum, treebootserial);
if (origin)
@@ -691,7 +692,7 @@ list_deployments_process_one_boot_entry (OstreeSysroot *self,
if (ostree_arg == NULL)
return glnx_throw (error, "No ostree= kernel argument found");
glnx_unref_object OstreeDeployment *deployment = NULL;
g_autoptr(OstreeDeployment) deployment = NULL;
if (!parse_deployment (self, ostree_arg, &deployment,
cancellable, error))
return FALSE;
@@ -999,7 +1000,7 @@ _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
GError **error)
{
gboolean is_active;
glnx_unref_object OstreeBootloader *ret_loader =
g_autoptr(OstreeBootloader) ret_loader =
(OstreeBootloader*)_ostree_bootloader_syslinux_new (sysroot);
if (!_ostree_bootloader_query (ret_loader, &is_active,
cancellable, error))
@@ -1078,7 +1079,7 @@ find_booted_deployment (OstreeSysroot *self,
{
struct stat root_stbuf;
struct stat self_stbuf;
glnx_unref_object OstreeDeployment *ret_deployment = NULL;
g_autoptr(OstreeDeployment) ret_deployment = NULL;
if (stat ("/", &root_stbuf) != 0)
return glnx_throw_errno_prefix (error, "stat /");
@@ -1549,7 +1550,7 @@ clone_deployment (OstreeSysroot *sysroot,
{
gboolean ret = FALSE;
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
glnx_unref_object OstreeDeployment *new_deployment = NULL;
g_autoptr(OstreeDeployment) new_deployment = NULL;
/* Ensure we have a clean slate */
if (!ostree_sysroot_prepare_cleanup (sysroot, cancellable, error))
@@ -1617,12 +1618,12 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
g_autoptr(OstreeSePolicy) sepolicy = NULL;
OstreeDeploymentUnlockedState current_unlocked =
ostree_deployment_get_unlocked (deployment);
glnx_unref_object OstreeDeployment *deployment_clone =
g_autoptr(OstreeDeployment) deployment_clone =
ostree_deployment_clone (deployment);
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
g_autoptr(OstreeDeployment) merge_deployment = NULL;
GKeyFile *origin_clone = ostree_deployment_get_origin (deployment_clone);
const char hotfix_ovl_options[] = "lowerdir=usr,upperdir=.usr-ovl-upper,workdir=.usr-ovl-work";
const char *ovl_options = NULL;
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
typedef struct _OstreeTlsCertInteraction OstreeTlsCertInteraction;
typedef struct _OstreeTlsCertInteractionClass OstreeTlsCertInteractionClass;
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeTlsCertInteraction, g_object_unref)
GType _ostree_tls_cert_interaction_get_type (void) G_GNUC_CONST;