Switch to glib cleanup macros

We don't have a lot of outstanding changes to the C code, so now seems
like a good time to do this.  I implemented this with some highly
sophisticated sed commands like:

```
find -name '*.c' | while read name; do sed -i -e 's,gs_unref_object \([A-Za-z]*\) \*,g_autoptr(\1),' ${name}; done
```

Part of dropping the dependency on libgsystem, same as what we're
doing in ostree.

Closes: #393
Approved by: jlebon
This commit is contained in:
Colin Walters 2016-07-14 23:12:37 -04:00 committed by Atomic Bot
parent 7888b9d7db
commit cc2551dc06
18 changed files with 200 additions and 197 deletions

View File

@ -56,8 +56,8 @@ CLEANFILES += \
tests/common/compose/test-repo-local.repo \
$(NULL)
tests_check_jsonutil_CPPFLAGS = -I $(srcdir)/src/libpriv
tests_check_jsonutil_CFLAGS = $(PKGDEP_RPMOSTREE_CFLAGS)
tests_check_jsonutil_CPPFLAGS = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx
tests_check_jsonutil_CFLAGS = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS)
tests_check_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la
tests/check/test-compose.sh: tests/common/compose/test-repo.repo

View File

@ -224,7 +224,7 @@ main (int argc,
int exit_status = EXIT_SUCCESS;
int in, out;
const char *command_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
GError *local_error = NULL;
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
@ -280,7 +280,7 @@ main (int argc,
if (!command)
{
GOptionContext *context;
gs_free char *help = NULL;
g_autofree char *help = NULL;
context = option_context_new_with_commands ();

View File

@ -68,7 +68,7 @@ rpmostree_builtin_compose (int argc, char **argv, GCancellable *cancellable, GEr
{
RpmOstreeComposeCommand *subcommand;
const char *subcommand_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
int exit_status = EXIT_SUCCESS;
int in, out;
@ -106,7 +106,7 @@ rpmostree_builtin_compose (int argc, char **argv, GCancellable *cancellable, GEr
if (!subcommand->name)
{
GOptionContext *context;
gs_free char *help = NULL;
g_autofree char *help = NULL;
context = compose_option_context_new_with_commands ();

View File

@ -65,7 +65,7 @@ rpmostree_builtin_container (int argc, char **argv, GCancellable *cancellable, G
{
RpmOstreeContainerCommand *subcommand;
const char *subcommand_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
int exit_status = EXIT_SUCCESS;
int in, out;
@ -103,7 +103,7 @@ rpmostree_builtin_container (int argc, char **argv, GCancellable *cancellable, G
if (!subcommand->name)
{
GOptionContext *context;
gs_free char *help = NULL;
g_autofree char *help = NULL;
context = container_option_context_new_with_commands ();

View File

@ -73,7 +73,7 @@ rpmostree_db_option_context_parse (GOptionContext *context,
OstreeRepo **out_repo,
GCancellable *cancellable, GError **error)
{
gs_unref_object OstreeRepo *repo = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
gboolean success = FALSE;
/* Entries are listed in --help output in the order added. We add the
@ -92,7 +92,7 @@ rpmostree_db_option_context_parse (GOptionContext *context,
if (opt_repo == NULL)
{
gs_unref_object OstreeSysroot *sysroot = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;
sysroot = ostree_sysroot_new_default ();
if (!ostree_sysroot_load (sysroot, cancellable, error))
@ -103,7 +103,7 @@ rpmostree_db_option_context_parse (GOptionContext *context,
}
else
{
gs_unref_object GFile *repo_file = g_file_new_for_path (opt_repo);
g_autoptr(GFile) repo_file = g_file_new_for_path (opt_repo);
repo = ostree_repo_new (repo_file);
if (!ostree_repo_open (repo, cancellable, error))
@ -129,7 +129,7 @@ rpmostree_builtin_db (int argc, char **argv, GCancellable *cancellable, GError *
{
RpmOstreeDbCommand *subcommand;
const char *subcommand_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
int exit_status = EXIT_SUCCESS;
int in, out;
@ -167,7 +167,7 @@ rpmostree_builtin_db (int argc, char **argv, GCancellable *cancellable, GError *
if (!subcommand->name)
{
GOptionContext *context;
gs_free char *help = NULL;
g_autofree char *help = NULL;
context = rpm_option_context_new_with_commands ();

View File

@ -68,7 +68,7 @@ rpmostree_builtin_internals (int argc, char **argv, GCancellable *cancellable, G
{
RpmOstreeInternalsCommand *subcommand;
const char *subcommand_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
int exit_status = EXIT_SUCCESS;
int in, out;
@ -106,7 +106,7 @@ rpmostree_builtin_internals (int argc, char **argv, GCancellable *cancellable, G
if (!subcommand->name)
{
GOptionContext *context;
gs_free char *help = NULL;
g_autofree char *help = NULL;
context = internals_option_context_new_with_commands ();

View File

@ -27,6 +27,7 @@
#include "rpmostree-libbuiltin.h"
#include "libgsystem.h"
#include "libglnx.h"
static char *opt_repo_path;
static char *opt_key_id;
@ -47,17 +48,17 @@ rpmostree_compose_builtin_sign (int argc,
{
int exit_status = EXIT_FAILURE;
GOptionContext *context = g_option_context_new ("- Use rpm-sign to sign an OSTree commit");
gs_unref_object GFile *repopath = NULL;
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GFile *tmp_commitdata_file = NULL;
gs_unref_object GFileIOStream *tmp_sig_stream = NULL;
gs_unref_object GFile *tmp_sig_file = NULL;
gs_unref_object GFileIOStream *tmp_commitdata_stream = NULL;
g_autoptr(GFile) repopath = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GFile) tmp_commitdata_file = NULL;
g_autoptr(GFileIOStream) tmp_sig_stream = NULL;
g_autoptr(GFile) tmp_sig_file = NULL;
g_autoptr(GFileIOStream) tmp_commitdata_stream = NULL;
GOutputStream *tmp_commitdata_output = NULL;
gs_unref_object GInputStream *commit_data = NULL;
gs_free char *checksum = NULL;
gs_unref_variant GVariant *commit_variant = NULL;
gs_unref_bytes GBytes *commit_bytes = NULL;
g_autoptr(GInputStream) commit_data = NULL;
g_autofree char *checksum = NULL;
g_autoptr(GVariant) commit_variant = NULL;
g_autoptr(GBytes) commit_bytes = NULL;
if (!rpmostree_option_context_parse (context,
option_entries,
@ -120,7 +121,7 @@ rpmostree_compose_builtin_sign (int argc,
{
char *sigcontent = NULL;
gsize len;
gs_unref_bytes GBytes *sigbytes = NULL;
g_autoptr(GBytes) sigbytes = NULL;
if (!g_file_load_contents (tmp_sig_file, cancellable, &sigcontent, &len, NULL,
error))

View File

@ -73,7 +73,7 @@ static GOptionEntry option_entries[] = {
static char *
checksum_version (GVariant *checksum)
{
gs_unref_variant GVariant *metadata = NULL;
g_autoptr(GVariant) metadata = NULL;
const char *ret = NULL;
metadata = g_variant_get_child_value (checksum, 0);
@ -106,7 +106,7 @@ compute_checksum_from_treefile_and_goal (RpmOstreeTreeComposeContext *self,
GError **error)
{
gboolean ret = FALSE;
gs_free char *ret_checksum = NULL;
g_autofree char *ret_checksum = NULL;
GChecksum *checksum = g_checksum_new (G_CHECKSUM_SHA256);
/* Hash in the raw treefile; this means reordering the input packages
@ -124,10 +124,10 @@ compute_checksum_from_treefile_and_goal (RpmOstreeTreeComposeContext *self,
guint i, len = json_array_get_length (add_files);
for (i = 0; i < len; i++)
{
gs_unref_object GFile *srcfile = NULL;
g_autoptr(GFile) srcfile = NULL;
const char *src, *dest;
JsonArray *add_el = json_array_get_array_element (add_files, i);
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
if (!add_el)
{
@ -226,7 +226,7 @@ install_packages_in_root (RpmOstreeTreeComposeContext *self,
GFile *contextdir = self->treefile_context_dirs->pdata[0];
g_autoptr(RpmOstreeInstall) hifinstall = { 0, };
HifContext *hifctx;
gs_free char *ret_new_inputhash = NULL;
g_autofree char *ret_new_inputhash = NULL;
g_autoptr(GKeyFile) treespec = g_key_file_new ();
JsonArray *enable_repos = NULL;
JsonArray *add_files = NULL;
@ -332,8 +332,8 @@ install_packages_in_root (RpmOstreeTreeComposeContext *self,
/* Only look for previous checksum if caller has passed *out_unmodified */
if (self->previous_checksum && out_unmodified != NULL)
{
gs_unref_variant GVariant *commit_v = NULL;
gs_unref_variant GVariant *commit_metadata = NULL;
g_autoptr(GVariant) commit_v = NULL;
g_autoptr(GVariant) commit_metadata = NULL;
const char *previous_inputhash = NULL;
if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_COMMIT,
@ -366,7 +366,7 @@ install_packages_in_root (RpmOstreeTreeComposeContext *self,
goto out;
{ g_auto(GLnxConsoleRef) console = { 0, };
gs_unref_object HifState *hifstate = hif_state_new ();
glnx_unref_object HifState *hifstate = hif_state_new ();
progress_sigid = g_signal_connect (hifstate, "percentage-changed",
G_CALLBACK (on_hifstate_percentage_changed),
@ -411,7 +411,7 @@ process_includes (RpmOstreeTreeComposeContext *self,
}
{
gs_unref_object GFile *parent = g_file_get_parent (treefile_path);
g_autoptr(GFile) parent = g_file_get_parent (treefile_path);
gboolean existed = FALSE;
if (self->treefile_context_dirs->len > 0)
{
@ -431,9 +431,9 @@ process_includes (RpmOstreeTreeComposeContext *self,
if (include_path)
{
gs_unref_object GFile *treefile_dirpath = g_file_get_parent (treefile_path);
gs_unref_object GFile *parent_path = g_file_resolve_relative_path (treefile_dirpath, include_path);
gs_unref_object JsonParser *parent_parser = json_parser_new ();
g_autoptr(GFile) treefile_dirpath = g_file_get_parent (treefile_path);
g_autoptr(GFile) parent_path = g_file_resolve_relative_path (treefile_dirpath, include_path);
glnx_unref_object JsonParser *parent_parser = json_parser_new ();
JsonNode *parent_rootval;
JsonObject *parent_root;
GList *members;
@ -520,7 +520,7 @@ parse_keyvalue_strings (char **strings,
{
const char *s;
const char *eq;
gs_free char *key = NULL;
g_autofree char *key = NULL;
s = *iter;
@ -573,19 +573,19 @@ rpmostree_compose_builtin_tree (int argc,
RpmOstreeTreeComposeContext *self = &selfdata;
JsonNode *treefile_rootval = NULL;
JsonObject *treefile = NULL;
gs_free char *cachekey = NULL;
gs_free char *new_inputhash = NULL;
gs_unref_object GFile *previous_root = NULL;
gs_free char *previous_checksum = NULL;
gs_unref_object GFile *yumroot = NULL;
gs_unref_object GFile *yumroot_varcache = NULL;
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_ptrarray GPtrArray *bootstrap_packages = NULL;
gs_unref_ptrarray GPtrArray *packages = NULL;
gs_unref_object GFile *treefile_path = NULL;
gs_unref_object GFile *treefile_dirpath = NULL;
gs_unref_object GFile *repo_path = NULL;
gs_unref_object JsonParser *treefile_parser = NULL;
g_autofree char *cachekey = NULL;
g_autofree char *new_inputhash = NULL;
g_autoptr(GFile) previous_root = NULL;
g_autofree char *previous_checksum = NULL;
g_autoptr(GFile) yumroot = NULL;
g_autoptr(GFile) yumroot_varcache = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GPtrArray) bootstrap_packages = NULL;
g_autoptr(GPtrArray) packages = NULL;
g_autoptr(GFile) treefile_path = NULL;
g_autoptr(GFile) treefile_dirpath = NULL;
g_autoptr(GFile) repo_path = NULL;
glnx_unref_object JsonParser *treefile_parser = NULL;
gs_unref_variant_builder GVariantBuilder *metadata_builder =
g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
g_autoptr(RpmOstreeContext) corectx = NULL;
@ -635,7 +635,7 @@ rpmostree_compose_builtin_tree (int argc,
}
else
{
gs_free char *tmpd = NULL;
g_autofree char *tmpd = NULL;
if (!rpmostree_mkdtemp ("/var/tmp/rpm-ostree.XXXXXX", &tmpd, NULL, error))
goto out;
@ -716,8 +716,8 @@ rpmostree_compose_builtin_tree (int argc,
if (opt_print_only)
{
gs_unref_object JsonGenerator *generator = json_generator_new ();
gs_unref_object GOutputStream *stdout = g_unix_output_stream_new (1, FALSE);
glnx_unref_object JsonGenerator *generator = json_generator_new ();
g_autoptr(GOutputStream) stdout = g_unix_output_stream_new (1, FALSE);
json_generator_set_pretty (generator, TRUE);
json_generator_set_root (generator, treefile_rootval);
@ -761,9 +761,9 @@ rpmostree_compose_builtin_tree (int argc,
if (json_object_has_member (treefile, "automatic_version_prefix") &&
!compose_strv_contains_prefix (opt_metadata_strings, "version="))
{
gs_unref_variant GVariant *variant = NULL;
gs_free char *last_version = NULL;
gs_free char *next_version = NULL;
g_autoptr(GVariant) variant = NULL;
g_autofree char *last_version = NULL;
g_autofree char *next_version = NULL;
const char *ver_prefix;
ver_prefix = _rpmostree_jsonutil_object_require_string_member (treefile,
@ -798,7 +798,7 @@ rpmostree_compose_builtin_tree (int argc,
goto out;
g_ptr_array_add (packages, NULL);
{ gs_unref_object JsonGenerator *generator = json_generator_new ();
{ glnx_unref_object JsonGenerator *generator = json_generator_new ();
char *treefile_buf = NULL;
gsize len;
@ -880,7 +880,7 @@ rpmostree_compose_builtin_tree (int argc,
{
const char *gpgkey;
gboolean selinux = TRUE;
gs_unref_variant GVariant *metadata = NULL;
g_autoptr(GVariant) metadata = NULL;
g_variant_builder_add (metadata_builder, "{sv}",
"rpmostree.inputhash",

View File

@ -36,7 +36,7 @@ rpmostree_db_builtin_diff (int argc, char **argv, GCancellable *cancellable, GEr
{
int exit_status = EXIT_FAILURE;
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
struct RpmRevisionData *rpmrev1 = NULL;
struct RpmRevisionData *rpmrev2 = NULL;

View File

@ -44,8 +44,8 @@ _builtin_db_list (OstreeRepo *repo,
if (mrev)
{
gs_unref_ptrarray GPtrArray *range_revs = NULL;
gs_free char *revdup = g_strdup (rev);
g_autoptr(GPtrArray) range_revs = NULL;
g_autofree char *revdup = g_strdup (rev);
mrev = revdup + (mrev - rev);
*mrev = 0;
@ -89,9 +89,9 @@ rpmostree_db_builtin_list (int argc, char **argv, GCancellable *cancellable, GEr
{
int exit_status = EXIT_FAILURE;
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_ptrarray GPtrArray *patterns = NULL;
gs_unref_ptrarray GPtrArray *revs = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GPtrArray) patterns = NULL;
g_autoptr(GPtrArray) revs = NULL;
int ii;
context = g_option_context_new ("[PREFIX-PKGNAME...] COMMIT... - List packages within commits");
@ -112,7 +112,7 @@ rpmostree_db_builtin_list (int argc, char **argv, GCancellable *cancellable, GEr
g_ptr_array_add (patterns, argv[ii]);
else
{
gs_free char *commit = NULL;
g_autofree char *commit = NULL;
ostree_repo_resolve_rev (repo, argv[ii], TRUE, &commit, NULL);

View File

@ -39,13 +39,13 @@ _builtin_db_version (OstreeRepo *repo, GPtrArray *revs,
{
char *rev = revs->pdata[num];
_cleanup_rpmrev_ struct RpmRevisionData *rpmrev = NULL;
gs_free char *rpmdbv = NULL;
g_autofree char *rpmdbv = NULL;
char *mrev = strstr (rev, "..");
if (mrev)
{
gs_unref_ptrarray GPtrArray *range_revs = NULL;
gs_free char *revdup = g_strdup (rev);
g_autoptr(GPtrArray) range_revs = NULL;
g_autofree char *revdup = g_strdup (rev);
mrev = revdup + (mrev - rev);
*mrev = 0;
@ -94,8 +94,8 @@ rpmostree_db_builtin_version (int argc, char **argv, GCancellable *cancellable,
{
int exit_status = EXIT_FAILURE;
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_ptrarray GPtrArray *revs = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GPtrArray) revs = NULL;
gint ii;
context = g_option_context_new ("COMMIT... - Show rpmdb version of packages within the commits");

View File

@ -258,10 +258,10 @@ on_log_handler (const gchar *log_domain,
static gboolean
connect_to_peer (int fd)
{
gs_unref_object GSocketConnection *stream = NULL;
gs_unref_object GSocket *socket = NULL;
g_autoptr(GSocketConnection) stream = NULL;
g_autoptr(GSocket) socket = NULL;
GError *error = NULL;
gs_free gchar *guid = NULL;
g_autofree gchar *guid = NULL;
gboolean ret = FALSE;
socket = g_socket_new_from_fd (fd, &error);

View File

@ -663,7 +663,7 @@ rpmostree_context_download_metadata (RpmOstreeContext *self,
{
gboolean ret = FALSE;
guint progress_sigid;
gs_unref_object HifState *hifstate = hif_state_new ();
glnx_unref_object HifState *hifstate = hif_state_new ();
progress_sigid = g_signal_connect (hifstate, "percentage-changed",
G_CALLBACK (on_hifstate_percentage_changed),
@ -1123,7 +1123,7 @@ rpmostree_context_download (RpmOstreeContext *ctx,
g_autofree char *target_dir = NULL;
HifRepo *src = key;
GPtrArray *src_packages = value;
gs_unref_object HifState *hifstate = hif_state_new ();
glnx_unref_object HifState *hifstate = hif_state_new ();
g_autofree char *prefix
= g_strdup_printf (" Downloading from %s:", hif_repo_get_id (src));
@ -1845,7 +1845,7 @@ run_posttrans_sync (int tmp_metadata_dfd,
static char *
checksum_version (GVariant *checksum)
{
gs_unref_variant GVariant *metadata = NULL;
g_autoptr(GVariant) metadata = NULL;
const char *ret = NULL;
metadata = g_variant_get_child_value (checksum, 0);

View File

@ -72,7 +72,7 @@ dir_contains_uid_or_gid (GFile *root,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFileInfo *file_info = NULL;
g_autoptr(GFileInfo) file_info = NULL;
guint32 type;
guint32 tid;
gboolean found_match = FALSE;
@ -109,8 +109,8 @@ dir_contains_uid_or_gid (GFile *root,
/* Now recurse for dirs. */
if (!found_match && type == G_FILE_TYPE_DIRECTORY)
{
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
dir_enum = g_file_enumerate_children (root, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@ -282,14 +282,14 @@ rpmostree_check_passwd_groups (gboolean passwd,
const char *commit_filepath = passwd ? "usr/lib/passwd" : "usr/lib/group";
const char *json_conf_name = passwd ? "check-passwd" : "check-groups";
const char *json_conf_ign = passwd ? "ignore-removed-users" : "ignore-removed-groups";
gs_unref_object GFile *old_path = NULL;
gs_unref_object GFile *new_path = g_file_resolve_relative_path (yumroot, commit_filepath);
gs_unref_ptrarray GPtrArray *ignore_removed_ents = NULL;
g_autoptr(GFile) old_path = NULL;
g_autoptr(GFile) new_path = g_file_resolve_relative_path (yumroot, commit_filepath);
g_autoptr(GPtrArray) ignore_removed_ents = NULL;
gboolean ignore_all_removed = FALSE;
gs_free char *old_contents = NULL;
gs_free char *new_contents = NULL;
gs_unref_ptrarray GPtrArray *old_ents = NULL;
gs_unref_ptrarray GPtrArray *new_ents = NULL;
g_autofree char *old_contents = NULL;
g_autofree char *new_contents = NULL;
g_autoptr(GPtrArray) old_ents = NULL;
g_autoptr(GPtrArray) new_ents = NULL;
unsigned int oiter = 0;
unsigned int niter = 0;
@ -403,7 +403,7 @@ rpmostree_check_passwd_groups (gboolean passwd,
{
if (previous_commit != NULL)
{
gs_unref_object GFile *root = NULL;
g_autoptr(GFile) root = NULL;
if (!ostree_repo_read_commit (repo, previous_commit, &root, NULL, NULL, error))
goto out;
@ -714,9 +714,9 @@ rpmostree_passwd_migrate_except_root (GFile *rootfs,
{
gboolean ret = FALSE;
const char *name = kind == RPM_OSTREE_PASSWD_MIGRATE_PASSWD ? "passwd" : "group";
gs_free char *src_path = g_strconcat (gs_file_get_path_cached (rootfs), "/etc/", name, NULL);
gs_free char *etctmp_path = g_strconcat (gs_file_get_path_cached (rootfs), "/etc/", name, ".tmp", NULL);
gs_free char *usrdest_path = g_strconcat (gs_file_get_path_cached (rootfs), "/usr/lib/", name, NULL);
g_autofree char *src_path = g_strconcat (gs_file_get_path_cached (rootfs), "/etc/", name, NULL);
g_autofree char *etctmp_path = g_strconcat (gs_file_get_path_cached (rootfs), "/etc/", name, ".tmp", NULL);
g_autofree char *usrdest_path = g_strconcat (gs_file_get_path_cached (rootfs), "/usr/lib/", name, NULL);
_cleanup_stdio_file_ FILE *src_stream = NULL;
_cleanup_stdio_file_ FILE *etcdest_stream = NULL;
_cleanup_stdio_file_ FILE *usrdest_stream = NULL;
@ -829,8 +829,8 @@ target_etc_filename (GFile *yumroot,
GError **error)
{
FILE *ret = NULL;
gs_free char *etc_subpath = g_strconcat ("etc/", filename, NULL);
gs_free char *target_etc =
g_autofree char *etc_subpath = g_strconcat ("etc/", filename, NULL);
g_autofree char *target_etc =
g_build_filename (gs_file_get_path_cached (yumroot), etc_subpath, NULL);
ret = gfopen (target_etc, "w", cancellable, error);
@ -946,16 +946,16 @@ concat_passwd_file (GFile *yumroot,
{
gboolean ret = FALSE;
const char *filename = kind == RPM_OSTREE_PASSWD_MIGRATE_PASSWD ? "passwd" : "group";
gs_free char *usretc_subpath = g_strconcat ("usr/etc/", filename, NULL);
gs_free char *usrlib_subpath = g_strconcat ("usr/lib/", filename, NULL);
gs_unref_object GFile *orig_etc_content =
g_autofree char *usretc_subpath = g_strconcat ("usr/etc/", filename, NULL);
g_autofree char *usrlib_subpath = g_strconcat ("usr/lib/", filename, NULL);
g_autoptr(GFile) orig_etc_content =
g_file_resolve_relative_path (previous_commit, usretc_subpath);
gs_unref_object GFile *orig_usrlib_content =
g_autoptr(GFile) orig_usrlib_content =
g_file_resolve_relative_path (previous_commit, usrlib_subpath);
gs_unref_object GFileOutputStream *out = NULL;
gs_unref_hashtable GHashTable *seen_names =
g_autoptr(GFileOutputStream) out = NULL;
g_autoptr(GHashTable) seen_names =
g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
gs_free char *contents = NULL;
g_autofree char *contents = NULL;
GFile *sources[] = { orig_etc_content, orig_usrlib_content };
guint i;
gboolean have_etc, have_usr;
@ -1019,9 +1019,9 @@ _data_from_json (GFile *yumroot,
JsonObject *chk = NULL;
const char *chk_type = NULL;
const char *filename = NULL;
gs_unref_object GFile *source = NULL;
gs_free char *contents = NULL;
gs_unref_hashtable GHashTable *seen_names =
g_autoptr(GFile) source = NULL;
g_autofree char *contents = NULL;
g_autoptr(GHashTable) seen_names =
g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
_cleanup_stdio_file_ FILE *src_stream = NULL;
_cleanup_stdio_file_ FILE *dest_stream = NULL;
@ -1088,7 +1088,7 @@ rpmostree_generate_passwd_from_previous (OstreeRepo *repo,
gboolean found_passwd_data = FALSE;
gboolean found_groups_data = FALSE;
gboolean perform_migrate = FALSE;
gs_unref_object GFile *yumroot_etc = g_file_resolve_relative_path (yumroot, "etc");
g_autoptr(GFile) yumroot_etc = g_file_resolve_relative_path (yumroot, "etc");
/* Create /etc in the target root; FIXME - should ensure we're using
* the right permissions from the filesystem RPM. Doing this right

View File

@ -54,7 +54,7 @@ move_to_dir (GFile *src,
GCancellable *cancellable,
GError **error)
{
gs_unref_object GFile *dest =
g_autoptr(GFile) dest =
g_file_get_child (dest_dir, gs_file_get_basename_cached (src));
return gs_file_rename (src, dest, cancellable, error);
@ -95,7 +95,7 @@ init_rootfs (GFile *targetroot,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
guint i;
const char *toplevel_dirs[] = { "dev", "proc", "run", "sys", "var", "sysroot" };
const Symlink symlinks[] = {
@ -115,7 +115,7 @@ init_rootfs (GFile *targetroot,
for (i = 0; i < G_N_ELEMENTS (toplevel_dirs); i++)
{
gs_unref_object GFile *dir = g_file_get_child (targetroot, toplevel_dirs[i]);
g_autoptr(GFile) dir = g_file_get_child (targetroot, toplevel_dirs[i]);
if (!gs_file_ensure_directory (dir, TRUE,
cancellable, error))
@ -125,7 +125,7 @@ init_rootfs (GFile *targetroot,
for (i = 0; i < G_N_ELEMENTS (symlinks); i++)
{
const Symlink*linkinfo = symlinks + i;
gs_unref_object GFile *src =
g_autoptr(GFile) src =
g_file_resolve_relative_path (targetroot, linkinfo->src);
if (!g_file_make_symbolic_link (src, linkinfo->target,
@ -146,9 +146,9 @@ find_kernel_and_initramfs_in_bootdir (GFile *bootdir,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFileEnumerator *direnum = NULL;
gs_unref_object GFile *ret_kernel = NULL;
gs_unref_object GFile *ret_initramfs = NULL;
g_autoptr(GFileEnumerator) direnum = NULL;
g_autoptr(GFile) ret_kernel = NULL;
g_autoptr(GFile) ret_initramfs = NULL;
direnum = g_file_enumerate_children (bootdir, "standard::name", 0,
cancellable, error);
@ -212,8 +212,8 @@ find_ensure_one_subdirectory (GFile *d,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFileEnumerator *direnum = NULL;
gs_unref_object GFile *ret_subdir = NULL;
g_autoptr(GFileEnumerator) direnum = NULL;
g_autoptr(GFile) ret_subdir = NULL;
direnum = g_file_enumerate_children (d, "standard::name,standard::type", 0,
cancellable, error);
@ -316,10 +316,10 @@ do_kernel_prep (GFile *yumroot,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *bootdir =
g_autoptr(GFile) bootdir =
g_file_get_child (yumroot, "boot");
gs_unref_object GFile *kernel_path = NULL;
gs_unref_object GFile *initramfs_path = NULL;
g_autoptr(GFile) kernel_path = NULL;
g_autoptr(GFile) initramfs_path = NULL;
const char *boot_checksum_str = NULL;
GChecksum *boot_checksum = NULL;
g_autofree char *kver = NULL;
@ -331,8 +331,8 @@ do_kernel_prep (GFile *yumroot,
if (kernel_path == NULL)
{
gs_unref_object GFile *mod_dir = g_file_resolve_relative_path (yumroot, "usr/lib/modules");
gs_unref_object GFile *modversion_dir = NULL;
g_autoptr(GFile) mod_dir = g_file_resolve_relative_path (yumroot, "usr/lib/modules");
g_autoptr(GFile) modversion_dir = NULL;
if (!find_ensure_one_subdirectory (mod_dir, &modversion_dir, cancellable, error))
goto out;
@ -374,7 +374,7 @@ do_kernel_prep (GFile *yumroot,
/* OSTree needs to own this */
{
gs_unref_object GFile *loaderdir = g_file_get_child (bootdir, "loader");
g_autoptr(GFile) loaderdir = g_file_get_child (bootdir, "loader");
if (!gs_shutil_rm_rf (loaderdir, cancellable, error))
goto out;
}
@ -391,7 +391,7 @@ do_kernel_prep (GFile *yumroot,
g_print ("Creating empty machine-id\n");
{
const char *hardcoded_machine_id = "";
gs_unref_object GFile *machineid_path =
g_autoptr(GFile) machineid_path =
g_file_resolve_relative_path (yumroot, "etc/machine-id");
if (!g_file_replace_contents (machineid_path, hardcoded_machine_id,
strlen (hardcoded_machine_id),
@ -402,7 +402,7 @@ do_kernel_prep (GFile *yumroot,
{
gboolean reproducible;
gs_unref_ptrarray GPtrArray *dracut_argv = g_ptr_array_new ();
g_autoptr(GPtrArray) dracut_argv = g_ptr_array_new ();
if (!dracut_supports_reproducible (yumroot, &reproducible, cancellable, error))
goto out;
@ -454,8 +454,8 @@ do_kernel_prep (GFile *yumroot,
}
{
gs_free char *initramfs_name = g_strconcat ("initramfs-", kver, ".img", NULL);
gs_unref_object GFile *initramfs_dest =
g_autofree char *initramfs_name = g_strconcat ("initramfs-", kver, ".img", NULL);
g_autoptr(GFile) initramfs_dest =
g_file_get_child (bootdir, initramfs_name);
if (!gs_file_rename (initramfs_path, initramfs_dest,
@ -479,15 +479,15 @@ do_kernel_prep (GFile *yumroot,
boot_checksum_str = g_checksum_get_string (boot_checksum);
{
gs_free char *new_kernel_name =
g_autofree char *new_kernel_name =
g_strconcat (gs_file_get_basename_cached (kernel_path), "-",
boot_checksum_str, NULL);
gs_unref_object GFile *new_kernel_path =
g_autoptr(GFile) new_kernel_path =
g_file_get_child (bootdir, new_kernel_name);
gs_free char *new_initramfs_name =
g_autofree char *new_initramfs_name =
g_strconcat (gs_file_get_basename_cached (initramfs_path), "-",
boot_checksum_str, NULL);
gs_unref_object GFile *new_initramfs_path =
g_autoptr(GFile) new_initramfs_path =
g_file_get_child (bootdir, new_initramfs_name);
if (!gs_file_rename (kernel_path, new_kernel_path,
@ -522,9 +522,9 @@ convert_var_to_tmpfiles_d_recurse (GOutputStream *tmpfiles_out,
{
struct dirent *dent = NULL;
GString *tmpfiles_d_buf;
gs_free char *tmpfiles_d_line = NULL;
g_autofree char *tmpfiles_d_line = NULL;
char filetype_c;
gs_free char *relpath = NULL;
g_autofree char *relpath = NULL;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, cancellable, error))
goto out;
@ -682,7 +682,7 @@ workaround_selinux_cross_labeling_recurse (int dfd,
{
struct stat stbuf;
const char *lastdot;
gs_free char *nonbin_name = NULL;
g_autofree char *nonbin_name = NULL;
if (TEMP_FAILURE_RETRY (fstatat (dfd_iter.fd, name, &stbuf, AT_SYMLINK_NOFOLLOW)) != 0)
{
@ -754,10 +754,10 @@ replace_nsswitch (GFile *target_usretc,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *nsswitch_conf =
g_autoptr(GFile) nsswitch_conf =
g_file_get_child (target_usretc, "nsswitch.conf");
gs_free char *nsswitch_contents = NULL;
gs_free char *new_nsswitch_contents = NULL;
g_autofree char *nsswitch_contents = NULL;
g_autofree char *new_nsswitch_contents = NULL;
static gsize regex_initialized;
static GRegex *passwd_regex;
@ -803,9 +803,9 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
gboolean ret = FALSE;
glnx_fd_close int src_rootfs_fd = -1;
glnx_fd_close int target_root_dfd = -1;
gs_unref_object GFile *kernel_path = NULL;
gs_unref_object GFile *initramfs_path = NULL;
gs_unref_hashtable GHashTable *preserve_groups_set = NULL;
g_autoptr(GFile) kernel_path = NULL;
g_autoptr(GFile) initramfs_path = NULL;
g_autoptr(GHashTable) preserve_groups_set = NULL;
gboolean container = FALSE;
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (yumroot), TRUE,
@ -848,7 +848,7 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
/* NSS configuration to look at the new files */
{
gs_unref_object GFile *yumroot_etc =
g_autoptr(GFile) yumroot_etc =
g_file_resolve_relative_path (yumroot, "etc");
if (!replace_nsswitch (yumroot_etc, cancellable, error))
@ -858,8 +858,8 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
/* We take /usr from the yum content */
g_print ("Moving /usr and /etc to target\n");
{
gs_unref_object GFile *usr = g_file_get_child (yumroot, "usr");
gs_unref_object GFile *etc = g_file_get_child (yumroot, "etc");
g_autoptr(GFile) usr = g_file_get_child (yumroot, "usr");
g_autoptr(GFile) etc = g_file_get_child (yumroot, "etc");
if (!move_to_dir (usr, targetroot, cancellable, error))
goto out;
if (!move_to_dir (etc, targetroot, cancellable, error))
@ -877,13 +877,13 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
/* Move boot, but rename the kernel/initramfs to have a checksum */
if (!container)
{
gs_unref_object GFile *yumroot_boot =
g_autoptr(GFile) yumroot_boot =
g_file_get_child (yumroot, "boot");
gs_unref_object GFile *target_boot =
g_autoptr(GFile) target_boot =
g_file_get_child (targetroot, "boot");
gs_unref_object GFile *target_usrlib =
g_autoptr(GFile) target_usrlib =
g_file_resolve_relative_path (targetroot, "usr/lib");
gs_unref_object GFile *target_usrlib_ostree_boot =
g_autoptr(GFile) target_usrlib_ostree_boot =
g_file_resolve_relative_path (target_usrlib, "ostree-boot");
RpmOstreePostprocessBootLocation boot_location =
RPMOSTREE_POSTPROCESS_BOOT_LOCATION_BOTH;
@ -953,7 +953,7 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
"bin", "sbin" };
for (i = 0; i < G_N_ELEMENTS (toplevel_links); i++)
{
gs_unref_object GFile *srcpath =
g_autoptr(GFile) srcpath =
g_file_get_child (yumroot, toplevel_links[i]);
if (g_file_query_file_type (srcpath, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == G_FILE_TYPE_SYMBOLIC_LINK)
@ -971,12 +971,12 @@ create_rootfs_from_yumroot_content (GFile *targetroot,
const char *pkglibdir_path
= g_getenv("RPMOSTREE_UNINSTALLED_PKGLIBDIR") ?: PKGLIBDIR;
gs_unref_object GFile *src_pkglibdir = g_file_new_for_path (pkglibdir_path);
gs_unref_object GFile *src_tmpfilesd =
g_autoptr(GFile) src_pkglibdir = g_file_new_for_path (pkglibdir_path);
g_autoptr(GFile) src_tmpfilesd =
g_file_get_child (src_pkglibdir, "rpm-ostree-0-integration.conf");
gs_unref_object GFile *target_tmpfilesd =
g_autoptr(GFile) target_tmpfilesd =
g_file_resolve_relative_path (targetroot, "usr/lib/tmpfiles.d/rpm-ostree-0-integration.conf");
gs_unref_object GFile *target_tmpfilesd_parent = g_file_get_parent (target_tmpfilesd);
g_autoptr(GFile) target_tmpfilesd_parent = g_file_get_parent (target_tmpfilesd);
if (!gs_file_ensure_directory (target_tmpfilesd_parent, TRUE, cancellable, error))
goto out;
@ -1041,7 +1041,7 @@ handle_remove_files_from_package (GFile *yumroot,
if (g_regex_match (regex, file, 0, NULL))
{
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
if (file[0] == '/')
file++;
@ -1268,8 +1268,8 @@ rpmostree_copy_additional_files (GFile *rootfs,
JsonArray *add = NULL;
guint i, len;
gs_free char *dest_rootfs_path = g_strconcat (gs_file_get_path_cached (rootfs), ".post", NULL);
gs_unref_object GFile *targetroot = g_file_new_for_path (dest_rootfs_path);
g_autofree char *dest_rootfs_path = g_strconcat (gs_file_get_path_cached (rootfs), ".post", NULL);
g_autoptr(GFile) targetroot = g_file_new_for_path (dest_rootfs_path);
if (json_object_has_member (treefile, "add-files"))
{
@ -1287,7 +1287,7 @@ rpmostree_copy_additional_files (GFile *rootfs,
const char *src, *dest;
JsonArray *add_el = json_array_get_array_element (add, i);
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
if (!add_el)
{
@ -1305,11 +1305,11 @@ rpmostree_copy_additional_files (GFile *rootfs,
goto out;
{
gs_unref_object GFile *srcfile = g_file_resolve_relative_path (context_directory, src);
g_autoptr(GFile) srcfile = g_file_resolve_relative_path (context_directory, src);
const char *rootfs_path = gs_file_get_path_cached (rootfs);
gs_free char *destpath = g_strconcat (rootfs_path, "/", dest, NULL);
gs_unref_object GFile *destfile = g_file_resolve_relative_path (targetroot, destpath);
gs_unref_object GFile *target_tmpfilesd_parent = g_file_get_parent (destfile);
g_autofree char *destpath = g_strconcat (rootfs_path, "/", dest, NULL);
g_autoptr(GFile) destfile = g_file_resolve_relative_path (targetroot, destpath);
g_autoptr(GFile) target_tmpfilesd_parent = g_file_get_parent (destfile);
g_print ("Adding file '%s'\n", dest);
@ -1352,7 +1352,7 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
len = 0;
{
gs_unref_object GFile *multiuser_wants_dir =
g_autoptr(GFile) multiuser_wants_dir =
g_file_resolve_relative_path (yumroot, "etc/systemd/system/multi-user.target.wants");
if (!gs_file_ensure_directory (multiuser_wants_dir, TRUE, cancellable, error))
@ -1361,8 +1361,8 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
for (i = 0; i < len; i++)
{
const char *unitname = _rpmostree_jsonutil_array_require_string_element (units, i, error);
gs_unref_object GFile *unit_link_target = NULL;
gs_free char *symlink_target = NULL;
g_autoptr(GFile) unit_link_target = NULL;
g_autofree char *symlink_target = NULL;
if (!unitname)
goto out;
@ -1382,9 +1382,9 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
}
{
gs_unref_object GFile *target_treefile_dir_path =
g_autoptr(GFile) target_treefile_dir_path =
g_file_resolve_relative_path (yumroot, "usr/share/rpm-ostree");
gs_unref_object GFile *target_treefile_path =
g_autoptr(GFile) target_treefile_path =
g_file_get_child (target_treefile_dir_path, "treefile.json");
const guint8 *buf;
gsize len;
@ -1408,9 +1408,9 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
if (default_target != NULL)
{
gs_unref_object GFile *default_target_path =
g_autoptr(GFile) default_target_path =
g_file_resolve_relative_path (yumroot, "etc/systemd/system/default.target");
gs_free char *dest_default_target_path =
g_autofree char *dest_default_target_path =
g_strconcat ("/usr/lib/systemd/system/", default_target, NULL);
(void) gs_file_unlink (default_target_path, NULL, NULL);
@ -1431,7 +1431,7 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
for (i = 0; i < len; i++)
{
const char *val = _rpmostree_jsonutil_array_require_string_element (remove, i, error);
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
if (!val)
return FALSE;
@ -1469,7 +1469,7 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
* compatibility reasons using tmpfiles.
* */
{
gs_unref_object GFile *rpmdb =
g_autoptr(GFile) rpmdb =
g_file_resolve_relative_path (yumroot, "var/lib/rpm");
if (g_file_query_exists (rpmdb, NULL))
@ -1513,11 +1513,11 @@ rpmostree_treefile_postprocessing (GFile *yumroot,
if (postprocess_script)
{
const char *yumroot_path = gs_file_get_path_cached (yumroot);
gs_unref_object GFile *src = g_file_resolve_relative_path (context_directory, postprocess_script);
g_autoptr(GFile) src = g_file_resolve_relative_path (context_directory, postprocess_script);
const char *bn = gs_file_get_basename_cached (src);
gs_free char *binpath = g_strconcat ("/usr/bin/rpmostree-postprocess-", bn, NULL);
gs_free char *destpath = g_strconcat (yumroot_path, binpath, NULL);
gs_unref_object GFile *dest = g_file_new_for_path (destpath);
g_autofree char *binpath = g_strconcat ("/usr/bin/rpmostree-postprocess-", bn, NULL);
g_autofree char *destpath = g_strconcat (yumroot_path, binpath, NULL);
g_autoptr(GFile) dest = g_file_new_for_path (destpath);
/* Clone all the things */
if (!g_file_copy (src, dest, 0, cancellable, NULL, NULL, error))
@ -1562,7 +1562,7 @@ rpmostree_prepare_rootfs_for_commit (GFile *rootfs,
GError **error)
{
gboolean ret = FALSE;
gs_free char *dest_rootfs_path = NULL;
g_autofree char *dest_rootfs_path = NULL;
dest_rootfs_path = g_strconcat (gs_file_get_path_cached (rootfs), ".post", NULL);
@ -1570,7 +1570,7 @@ rpmostree_prepare_rootfs_for_commit (GFile *rootfs,
goto out;
{
gs_unref_object GFile *dest_rootfs = g_file_new_for_path (dest_rootfs_path);
g_autoptr(GFile) dest_rootfs = g_file_new_for_path (dest_rootfs_path);
if (!create_rootfs_from_yumroot_content (dest_rootfs, rootfs, treefile,
cancellable, error))
goto out;
@ -1601,7 +1601,7 @@ read_xattrs_cb (OstreeRepo *repo,
/* Hardcoded at the moment, we're only taking file caps */
static const char *accepted_xattrs[] = { "security.capability" };
guint i;
gs_unref_variant GVariant *existing_xattrs = NULL;
g_autoptr(GVariant) existing_xattrs = NULL;
gs_free_variant_iter GVariantIter *viter = NULL;
GError *local_error = NULL;
GError **error = &local_error;
@ -1663,12 +1663,12 @@ rpmostree_commit (int rootfs_fd,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object OstreeMutableTree *mtree = NULL;
glnx_unref_object OstreeMutableTree *mtree = NULL;
OstreeRepoCommitModifier *commit_modifier = NULL;
gs_free char *parent_revision = NULL;
gs_free char *new_revision = NULL;
gs_unref_object GFile *root_tree = NULL;
gs_unref_object OstreeSePolicy *sepolicy = NULL;
g_autofree char *parent_revision = NULL;
g_autofree char *new_revision = NULL;
g_autoptr(GFile) root_tree = NULL;
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
/* hardcode targeted policy for now */
if (enable_selinux)

View File

@ -120,7 +120,7 @@ pkg_nvr_strdup (Header h1)
static void
pkg_print (Header pkg)
{
gs_free char *nevra = pkg_nevra_strdup (pkg);
g_autofree char *nevra = pkg_nevra_strdup (pkg);
printf("%s\n", nevra);
}
@ -172,9 +172,9 @@ pat_fnmatch_match (Header pkg, const char *name,
gsize patprefixlen, const GPtrArray *patterns)
{
int num = 0;
gs_free char *pkg_na = NULL;
gs_free char *pkg_nevra = NULL;
gs_free char *pkg_nvr = NULL;
g_autofree char *pkg_na = NULL;
g_autofree char *pkg_nevra = NULL;
g_autofree char *pkg_nvr = NULL;
if (!patterns)
return TRUE;
@ -368,14 +368,14 @@ rpmhdrs_rpmdbv (struct RpmHeaders *l1,
GError **error)
{
GChecksum *checksum = g_checksum_new (G_CHECKSUM_SHA1);
gs_free char *checksum_cstr = NULL;
g_autofree char *checksum_cstr = NULL;
char *ret = NULL;
int num = 0;
while (num < l1->hs->len)
{
Header pkg = l1->hs->pdata[num++];
gs_free char *envra = pkg_envra_strdup (pkg);
g_autofree char *envra = pkg_envra_strdup (pkg);
g_checksum_update (checksum, (guint8*)envra, strlen(envra));
}
@ -509,7 +509,7 @@ rpmhdrs_diff_prnt_block (struct RpmHeadersDiff *diff)
while (ncnum > 0)
{
GDateTime *dt = NULL;
gs_free char *date_time_str = NULL;
g_autofree char *date_time_str = NULL;
/* Load next new %changelog entry, starting at the newest. */
rpmtdNext (nchanges_date);

View File

@ -47,7 +47,7 @@ _rpmostree_set_prefix_error_from_errno (GError **error,
const char *format,
...)
{
gs_free char *formatted = NULL;
g_autofree char *formatted = NULL;
va_list args;
va_start (args, format);
@ -195,7 +195,7 @@ _rpmostree_util_enumerate_directory_allow_noent (GFile *dirpath,
{
gboolean ret = FALSE;
GError *temp_error = NULL;
gs_unref_object GFileEnumerator *ret_direnum = NULL;
g_autoptr(GFileEnumerator) ret_direnum = NULL;
ret_direnum = g_file_enumerate_children (dirpath, queryargs, queryflags,
cancellable, &temp_error);
@ -226,7 +226,7 @@ _rpmostree_file_load_contents_utf8_allow_noent (GFile *path,
{
gboolean ret = FALSE;
GError *temp_error = NULL;
gs_free char *ret_contents = NULL;
g_autofree char *ret_contents = NULL;
ret_contents = gs_file_load_contents_utf8 (path, cancellable, &temp_error);
if (!ret_contents)
@ -257,7 +257,7 @@ _rpmostree_util_update_checksum_from_file (GChecksum *checksum,
gboolean ret = FALSE;
gsize bytes_read;
char buf[4096];
gs_unref_object GInputStream *filein = NULL;
g_autoptr(GInputStream) filein = NULL;
filein = (GInputStream*)g_file_read (src, cancellable, error);
if (!filein)
@ -282,8 +282,8 @@ static char *
ost_get_prev_commit (OstreeRepo *repo, char *checksum)
{
char *ret = NULL;
gs_unref_variant GVariant *commit = NULL;
gs_unref_variant GVariant *parent_csum_v = NULL;
g_autoptr(GVariant) commit = NULL;
g_autoptr(GVariant) parent_csum_v = NULL;
GError *tmp_error = NULL;
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum,
@ -306,9 +306,9 @@ _rpmostree_util_get_commit_hashes (OstreeRepo *repo,
GError **error)
{
GPtrArray *ret = NULL;
gs_free char *beg_checksum = NULL;
gs_free char *end_checksum = NULL;
gs_free char *parent = NULL;
g_autofree char *beg_checksum = NULL;
g_autofree char *end_checksum = NULL;
g_autofree char *parent = NULL;
char *checksum = NULL;
gboolean worked = FALSE;
@ -411,7 +411,7 @@ _rpmostree_util_keyfile_clone (GKeyFile *keyfile)
{
GKeyFile *ret = g_key_file_new ();
gsize len;
gs_free char *data = g_key_file_to_data (keyfile, &len, NULL);
g_autofree char *data = g_key_file_to_data (keyfile, &len, NULL);
gboolean loaded;
loaded = g_key_file_load_from_data (ret, data, len, 0, NULL);

View File

@ -1,9 +1,11 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-unix.h>
#include <libgsystem.h>
#include "libglnx.h"
#include "rpmostree-json-parsing.h"
#include "rpmostree-util.h"
@ -14,7 +16,7 @@ static JsonObject *
get_test_data (void)
{
GError *error = NULL;
gs_unref_object JsonParser *parser = json_parser_new ();
glnx_unref_object JsonParser *parser = json_parser_new ();
(void)json_parser_load_from_data (parser, test_data, -1, &error);
g_assert_no_error (error);
return json_object_ref (json_node_get_object (json_parser_get_root (parser)));