Use g_autoptr(GPtrArray) instead of gs_unref_ptrarray

This commit is contained in:
Matthew Barnes 2015-05-05 11:44:40 -04:00
parent 196d983af9
commit bb231fdf74
31 changed files with 60 additions and 61 deletions

View File

@ -138,7 +138,7 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot
gboolean ret = FALSE;
GString *output = g_string_new ("");
g_autoptr(GOutputStream) out_stream = NULL;
gs_unref_ptrarray GPtrArray *loader_configs = NULL;
g_autoptr(GPtrArray) loader_configs = NULL;
guint i;
gsize bytes_written;
gboolean is_efi;
@ -304,7 +304,7 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
if (ostree_sysroot_get_booted_deployment (self->sysroot) == NULL
&& g_file_has_parent (self->sysroot->path, NULL))
{
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
OstreeDeployment *tool_deployment;
g_autoptr(GFile) tool_deployment_root = NULL;

View File

@ -68,7 +68,7 @@ append_config_from_boostree_loader_entries (OstreeBootloaderSyslinux *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *boostree_loader_configs = NULL;
g_autoptr(GPtrArray) boostree_loader_configs = NULL;
guint i;
if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boostree_loader_configs,
@ -125,8 +125,8 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader,
g_autoptr(GFile) new_config_path = NULL;
g_autofree char *config_contents = NULL;
g_autofree char *new_config_contents = NULL;
gs_unref_ptrarray GPtrArray *new_lines = NULL;
gs_unref_ptrarray GPtrArray *tmp_lines = NULL;
g_autoptr(GPtrArray) new_lines = NULL;
g_autoptr(GPtrArray) tmp_lines = NULL;
g_autofree char *kernel_arg = NULL;
gboolean saw_default = FALSE;
gboolean regenerate_default = FALSE;

View File

@ -70,7 +70,7 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
GCancellable *cancellable,
GError **error)
{
gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
g_autoptr(GPtrArray) boot_loader_configs = NULL;
OstreeBootconfigParser *config;
const char *val;
@ -111,7 +111,7 @@ _ostree_bootloader_uboot_write_config (OstreeBootloader *bootloader,
g_autoptr(GFile) new_config_path = NULL;
g_autofree char *config_contents = NULL;
g_autofree char *new_config_contents = NULL;
gs_unref_ptrarray GPtrArray *new_lines = NULL;
g_autoptr(GPtrArray) new_lines = NULL;
/* This should follow the symbolic link to the current bootversion. */
config_contents = gs_file_load_contents_utf8 (self->config_path, cancellable, error);

View File

@ -428,7 +428,7 @@ ostree_raw_file_to_content_stream (GInputStream *input,
gsize header_size;
g_autoptr(GInputStream) ret_input = NULL;
gs_unref_variant GVariant *file_header = NULL;
gs_unref_ptrarray GPtrArray *streams = NULL;
g_autoptr(GPtrArray) streams = NULL;
g_autoptr(GOutputStream) header_out_stream = NULL;
g_autoptr(GInputStream) header_in_stream = NULL;

View File

@ -380,7 +380,7 @@ add_size_index_to_metadata (OstreeRepo *self,
OstreeContentSizeCacheEntry *e_size = NULL;
GVariantBuilder index_builder;
guint i;
gs_unref_ptrarray GPtrArray *sorted_keys = NULL;
g_autoptr(GPtrArray) sorted_keys = NULL;
g_hash_table_iter_init (&entries, self->object_sizes);
g_variant_builder_init (&index_builder,

View File

@ -123,8 +123,8 @@ write_libarchive_entry_to_mtree (OstreeRepo *self,
const char *hardlink;
const char *basename;
g_autoptr(GFileInfo) file_info = NULL;
gs_unref_ptrarray GPtrArray *split_path = NULL;
gs_unref_ptrarray GPtrArray *hardlink_split_path = NULL;
g_autoptr(GPtrArray) split_path = NULL;
g_autoptr(GPtrArray) hardlink_split_path = NULL;
glnx_unref_object OstreeMutableTree *subdir = NULL;
glnx_unref_object OstreeMutableTree *parent = NULL;
glnx_unref_object OstreeMutableTree *hardlink_source_parent = NULL;

View File

@ -220,7 +220,7 @@ ostree_repo_prune (OstreeRepo *self,
goto out;
}
{ gs_unref_ptrarray GPtrArray *deltas = NULL;
{ g_autoptr(GPtrArray) deltas = NULL;
guint i;
if (!ostree_repo_list_static_delta_names (self, &deltas,

View File

@ -153,7 +153,7 @@ build_content_sizenames_filtered (OstreeRepo *repo,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *ret_sizenames =
g_autoptr(GPtrArray) ret_sizenames =
g_ptr_array_new_with_free_func (_ostree_delta_content_sizenames_free);
g_autoptr(GHashTable) sizenames_map =
g_hash_table_new_full (g_str_hash, g_str_equal, NULL, _ostree_delta_content_sizenames_free);
@ -233,8 +233,8 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
gboolean ret = FALSE;
g_autoptr(GHashTable) ret_modified_regfile_content =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_ptr_array_unref);
gs_unref_ptrarray GPtrArray *from_sizes = NULL;
gs_unref_ptrarray GPtrArray *to_sizes = NULL;
g_autoptr(GPtrArray) from_sizes = NULL;
g_autoptr(GPtrArray) to_sizes = NULL;
guint i, j;
guint lower;
guint upper;

View File

@ -1249,7 +1249,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
guint64 total_compressed_size = 0;
guint64 total_uncompressed_size = 0;
gs_unref_variant_builder GVariantBuilder *part_headers = NULL;
gs_unref_ptrarray GPtrArray *part_tempfiles = NULL;
g_autoptr(GPtrArray) part_tempfiles = NULL;
gs_unref_variant GVariant *delta_descriptor = NULL;
gs_unref_variant GVariant *to_commit = NULL;
g_autofree char *descriptor_relpath = NULL;

View File

@ -68,7 +68,7 @@ ostree_repo_list_static_delta_names (OstreeRepo *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *ret_deltas = NULL;
g_autoptr(GPtrArray) ret_deltas = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
ret_deltas = g_ptr_array_new_with_free_func (g_free);

View File

@ -114,7 +114,7 @@ _ostree_compute_rollsum_matches (GBytes *from,
OstreeRollsumMatches *ret_rollsum = NULL;
g_autoptr(GHashTable) from_rollsum = NULL;
g_autoptr(GHashTable) to_rollsum = NULL;
gs_unref_ptrarray GPtrArray *matches = NULL;
g_autoptr(GPtrArray) matches = NULL;
const guint8 *from_buf;
gsize from_len;
const guint8 *to_buf;

View File

@ -99,7 +99,7 @@ list_all_deployment_directories (OstreeSysroot *self,
gboolean ret = FALSE;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFile) deploydir = NULL;
gs_unref_ptrarray GPtrArray *ret_deployments = NULL;
g_autoptr(GPtrArray) ret_deployments = NULL;
GError *temp_error = NULL;
deploydir = g_file_resolve_relative_path (self->path, "ostree/deploy");
@ -186,7 +186,7 @@ list_all_boot_directories (OstreeSysroot *self,
gboolean ret = FALSE;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFile) boot_ostree = NULL;
gs_unref_ptrarray GPtrArray *ret_bootdirs = NULL;
g_autoptr(GPtrArray) ret_bootdirs = NULL;
GError *temp_error = NULL;
boot_ostree = g_file_resolve_relative_path (self->path, "boot/ostree");
@ -296,8 +296,8 @@ cleanup_old_deployments (OstreeSysroot *self,
guint i;
g_autoptr(GHashTable) active_deployment_dirs = NULL;
g_autoptr(GHashTable) active_boot_checksums = NULL;
gs_unref_ptrarray GPtrArray *all_deployment_dirs = NULL;
gs_unref_ptrarray GPtrArray *all_boot_dirs = NULL;
g_autoptr(GPtrArray) all_deployment_dirs = NULL;
g_autoptr(GPtrArray) all_boot_dirs = NULL;
if (stat ("/", &root_stbuf) != 0)
{

View File

@ -369,9 +369,9 @@ merge_etc_changes (GFile *orig_etc,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *modified = NULL;
gs_unref_ptrarray GPtrArray *removed = NULL;
gs_unref_ptrarray GPtrArray *added = NULL;
g_autoptr(GPtrArray) modified = NULL;
g_autoptr(GPtrArray) removed = NULL;
g_autoptr(GPtrArray) added = NULL;
guint i;
int orig_etc_fd = -1;
int modified_etc_fd = -1;
@ -620,7 +620,7 @@ selinux_relabel_dir (OstreeSysroot *sysroot,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *path_parts = g_ptr_array_new ();
g_autoptr(GPtrArray) path_parts = g_ptr_array_new ();
g_autoptr(GFileInfo) root_info = NULL;
root_info = g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
@ -651,7 +651,7 @@ selinux_relabel_file (OstreeSysroot *sysroot,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *path_parts = g_ptr_array_new ();
g_autoptr(GPtrArray) path_parts = g_ptr_array_new ();
g_autoptr(GFileInfo) file_info = g_file_query_info (path, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
@ -1710,7 +1710,7 @@ allocate_deployserial (OstreeSysroot *self,
guint i;
int new_deployserial = 0;
g_autoptr(GFile) osdir = NULL;
gs_unref_ptrarray GPtrArray *tmp_current_deployments =
g_autoptr(GPtrArray) tmp_current_deployments =
g_ptr_array_new_with_free_func (g_object_unref);
osdir = ot_gfile_get_child_build_path (self->path, "ostree/deploy", osname, NULL);
@ -1922,7 +1922,7 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
{
gboolean ret = FALSE;
guint i;
gs_unref_ptrarray GPtrArray *new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
glnx_unref_object OstreeDeployment *new_deployment = NULL;
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
g_autofree char *new_options = NULL;

View File

@ -372,7 +372,7 @@ _ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
gboolean ret = FALSE;
int fd; /* Temporary owned by iterator */
g_autofree char *entries_path = g_strdup_printf ("boot/loader.%d/entries", bootversion);
gs_unref_ptrarray GPtrArray *ret_loader_configs = NULL;
g_autoptr(GPtrArray) ret_loader_configs = NULL;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!ensure_sysroot_fd (self, error))
@ -740,8 +740,8 @@ ostree_sysroot_load (OstreeSysroot *self,
guint i;
int bootversion = 0;
int subbootversion = 0;
gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) boot_loader_configs = NULL;
g_autoptr(GPtrArray) deployments = NULL;
g_clear_pointer (&self->deployments, g_ptr_array_unref);
g_clear_pointer (&self->booted_deployment, g_object_unref);
@ -1215,8 +1215,8 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
gboolean ret = FALSE;
guint i;
OstreeDeployment *booted_deployment = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
gs_unref_ptrarray GPtrArray *new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
g_autoptr(GPtrArray) deployments = NULL;
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
gboolean retain = (flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN) > 0;
deployments = ostree_sysroot_get_deployments (sysroot);

View File

@ -57,7 +57,7 @@ ot_gfile_from_build_path (const char *first, ...)
va_list args;
const char *arg;
g_autofree char *path = NULL;
gs_unref_ptrarray GPtrArray *components = NULL;
g_autoptr(GPtrArray) components = NULL;
va_start (args, first);
@ -114,7 +114,7 @@ ot_gfile_get_child_build_path (GFile *parent,
va_list args;
const char *arg;
g_autofree char *path = NULL;
gs_unref_ptrarray GPtrArray *components = NULL;
g_autoptr(GPtrArray) components = NULL;
va_start (args, first);

View File

@ -91,7 +91,7 @@ ot_util_path_split_validate (const char *path,
{
gboolean ret = FALSE;
int i;
gs_unref_ptrarray GPtrArray *ret_components = NULL;
g_autoptr(GPtrArray) ret_components = NULL;
if (strlen (path) > PATH_MAX)
{

View File

@ -58,7 +58,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
glnx_unref_object OstreeSysroot *sysroot = NULL;
GKeyFile *origin = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
gs_unref_ptrarray GPtrArray *new_deployments = NULL;
g_autoptr(GPtrArray) new_deployments = NULL;
glnx_unref_object OstreeDeployment *new_deployment = NULL;
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
g_autofree char *revision = NULL;

View File

@ -45,9 +45,9 @@ ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError
gboolean ret = FALSE;
glnx_unref_object OstreeDeployment *deployment = NULL;
g_autoptr(GFile) deployment_dir = NULL;
gs_unref_ptrarray GPtrArray *modified = NULL;
gs_unref_ptrarray GPtrArray *removed = NULL;
gs_unref_ptrarray GPtrArray *added = NULL;
g_autoptr(GPtrArray) modified = NULL;
g_autoptr(GPtrArray) removed = NULL;
g_autoptr(GPtrArray) added = NULL;
g_autoptr(GFile) orig_etc_path = NULL;
g_autoptr(GFile) new_etc_path = NULL;

View File

@ -89,7 +89,7 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
gboolean ret = FALSE;
glnx_unref_object OstreeRepo *repo = NULL;
OstreeDeployment *booted_deployment = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
guint i;
context = g_option_context_new ("List deployments");

View File

@ -40,7 +40,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
glnx_unref_object OstreeSysroot *sysroot = NULL;
const char *deploy_index_str;
int deploy_index;
gs_unref_ptrarray GPtrArray *current_deployments = NULL;
g_autoptr(GPtrArray) current_deployments = NULL;
glnx_unref_object OstreeDeployment *booted_deployment = NULL;
glnx_unref_object OstreeDeployment *target_deployment = NULL;

View File

@ -78,7 +78,7 @@ ot_admin_get_indexed_deployment (OstreeSysroot *sysroot,
GError **error)
{
gs_unref_ptrarray GPtrArray *current_deployments =
g_autoptr(GPtrArray) current_deployments =
ostree_sysroot_get_deployments (sysroot);
if (index < 0)

View File

@ -40,7 +40,7 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
guint bootversion;
g_autoptr(GFile) subpath = NULL;
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
GOptionContext *context = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;
g_autoptr(GFile) deployment_path = NULL;

View File

@ -152,7 +152,7 @@ selinux_relabel_dir (OstreeSePolicy *sepolicy,
GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *path_parts = g_ptr_array_new ();
g_autoptr(GPtrArray) path_parts = g_ptr_array_new ();
g_autoptr(GFileInfo) root_info = NULL;
root_info = g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
@ -186,7 +186,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
g_autoptr(GFile) subpath = NULL;
const char *prefix = NULL;
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment;
GOptionContext *context = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;

View File

@ -48,7 +48,7 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
{
gboolean ret = FALSE;
guint i;
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment = NULL;
GOptionContext *context = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;

View File

@ -126,9 +126,9 @@ ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **
g_autofree char *src_prev = NULL;
g_autoptr(GFile) srcf = NULL;
g_autoptr(GFile) targetf = NULL;
gs_unref_ptrarray GPtrArray *modified = NULL;
gs_unref_ptrarray GPtrArray *removed = NULL;
gs_unref_ptrarray GPtrArray *added = NULL;
g_autoptr(GPtrArray) modified = NULL;
g_autoptr(GPtrArray) removed = NULL;
g_autoptr(GPtrArray) added = NULL;
context = g_option_context_new ("REV TARGETDIR - Compare directory TARGETDIR against revision REV");
g_option_context_add_main_entries (context, options, NULL);

View File

@ -50,7 +50,7 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
GSConsole *console = NULL;
g_autofree char *src_repo_uri = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
gs_unref_ptrarray GPtrArray *refs_to_fetch = NULL;
g_autoptr(GPtrArray) refs_to_fetch = NULL;
g_autoptr(GHashTable) source_objects = NULL;
context = g_option_context_new ("SRC_REPO [REFS...] - Copy data from SRC_REPO");

View File

@ -63,7 +63,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
g_autofree char *remote = NULL;
OstreeRepoPullFlags pullflags = 0;
GSConsole *console = NULL;
gs_unref_ptrarray GPtrArray *refs_to_fetch = NULL;
g_autoptr(GPtrArray) refs_to_fetch = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
gulong signal_handler_id = 0;

View File

@ -97,7 +97,7 @@ static gboolean
ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
gs_unref_ptrarray GPtrArray *delta_names = NULL;
g_autoptr(GPtrArray) delta_names = NULL;
guint i;
GOptionContext *context;
glnx_unref_object OstreeRepo *repo = NULL;

View File

@ -339,7 +339,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
if (opt_print_current_dir)
{
gs_unref_ptrarray GPtrArray *deployments = NULL;
g_autoptr(GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment;
g_autoptr(GFile) deployment_file = NULL;
g_autofree char *deployment_path = NULL;

View File

@ -46,7 +46,7 @@ test_mutable_tree_walk (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
gs_unref_ptrarray GPtrArray *split_path = NULL;
g_autoptr(GPtrArray) split_path = NULL;
GError *error = NULL;
const char *pathname = "a/b/c/d/e/f/g/i";
const char *checksum = "01234567890123456789012345678901";
@ -84,7 +84,7 @@ test_ensure_parent_dirs (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
gs_unref_ptrarray GPtrArray *split_path = NULL;
g_autoptr(GPtrArray) split_path = NULL;
GError *error = NULL;
const char *pathname = "/foo/bar/baz";
const char *checksum = "01234567890123456789012345678901";
@ -111,7 +111,7 @@ test_ensure_dir (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
gs_unref_ptrarray GPtrArray *split_path = NULL;
g_autoptr(GPtrArray) split_path = NULL;
GError *error = NULL;
const char *dirname = "foo";
const char *filename = "bar";
@ -131,7 +131,7 @@ test_replace_file (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
gs_unref_ptrarray GPtrArray *split_path = NULL;
g_autoptr(GPtrArray) split_path = NULL;
GError *error = NULL;
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";

View File

@ -34,7 +34,7 @@ test_ot_util_path_split_validate (void)
for (i = 0; paths[i]; i++)
{
GError *error = NULL;
GPtrArray *components = NULL;
g_autoptr(GPtrArray) components = NULL;
if (! ot_util_path_split_validate (paths[i], &components, &error))
{
int j;
@ -45,7 +45,6 @@ test_ot_util_path_split_validate (void)
g_assert_null (strchr (components->pdata[i], '/'));
}
}
gs_local_ptrarray_unref (components);
}
}