[ostree] core: Drop ot_clear_gvariant() in favor of g_clear_pointer



commit 2ced4abf111aca46ba1365cfe8b00525f5ec4b9a
Author: Colin Walters <walters verbum org>
Date:   Tue Jul 17 08:14:33 2012 -0400

    core: Drop ot_clear_gvariant() in favor of g_clear_pointer

 src/libostree/ostree-core.c      |    2 +-
 src/libostree/ostree-repo-file.c |   18 +++++++++---------
 src/libostree/ostree-repo.c      |    6 +++---
 src/libostree/ostree-traverse.c  |    6 +++---
 src/libotutil/ot-variant-utils.h |    6 ------
 src/ostree/ot-builtin-fsck.c     |    4 ++--
 src/ostree/ot-builtin-log.c      |   12 ++++++------
 7 files changed, 24 insertions(+), 30 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 96673f4..2d61b18 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -729,7 +729,7 @@ ostree_set_xattrs (GFile  *f,
       value_data = g_variant_get_fixed_array (value, &value_len, 1);
       
       loop_err = lsetxattr (path, (char*)name, (char*)value_data, value_len, XATTR_REPLACE) < 0;
-      ot_clear_gvariant (&value);
+      g_clear_pointer (&value, (GDestroyNotify) g_variant_unref);
       if (loop_err)
         {
           ot_util_set_error_from_errno (error, errno);
diff --git a/src/libostree/ostree-repo-file.c b/src/libostree/ostree-repo-file.c
index dd82423..516f9f2 100644
--- a/src/libostree/ostree-repo-file.c
+++ b/src/libostree/ostree-repo-file.c
@@ -59,8 +59,8 @@ ostree_repo_file_finalize (GObject *object)
 
   self = OSTREE_REPO_FILE (object);
 
-  ot_clear_gvariant (&self->tree_contents);
-  ot_clear_gvariant (&self->tree_metadata);
+  g_clear_pointer (&self->tree_contents, (GDestroyNotify) g_variant_unref);
+  g_clear_pointer (&self->tree_metadata, (GDestroyNotify) g_variant_unref);
   g_free (self->cached_file_checksum);
   g_free (self->tree_contents_checksum);
   g_free (self->tree_metadata_checksum);
@@ -217,7 +217,7 @@ do_resolve_nonroot (OstreeRepoFile     *self,
 
       files_variant = g_variant_get_child_value (self->parent->tree_contents, 0);
       self->index = g_variant_n_children (files_variant) + i;
-      ot_clear_gvariant (&files_variant);
+      g_clear_pointer (&files_variant, (GDestroyNotify) g_variant_unref);
 
       g_variant_get_child (container, i, "(&s ay@ay)",
                            &name, &content_csum_v, &metadata_csum_v);
@@ -331,7 +331,7 @@ ostree_repo_file_tree_set_metadata (OstreeRepoFile *self,
                                      const char     *checksum,
                                      GVariant       *metadata)
 {
-  ot_clear_gvariant (&self->tree_metadata);
+  g_clear_pointer (&self->tree_metadata, (GDestroyNotify) g_variant_unref);
   self->tree_metadata = g_variant_ref (metadata);
   g_free (self->tree_metadata_checksum);
   self->tree_metadata_checksum = g_strdup (checksum);
@@ -396,8 +396,8 @@ ostree_repo_file_get_checksum (OstreeRepoFile  *self)
       g_variant_get_child (files_variant, n,
                            "(@s ay)", NULL, &csum_bytes);
     }
-  ot_clear_gvariant (&files_variant);
-  ot_clear_gvariant (&dirs_variant);
+  g_clear_pointer (&files_variant, (GDestroyNotify) g_variant_unref);
+  g_clear_pointer (&dirs_variant, (GDestroyNotify) g_variant_unref);
 
   self->cached_file_checksum = ostree_checksum_from_bytes_v (csum_bytes);
 
@@ -792,9 +792,9 @@ ostree_repo_file_tree_find_child  (OstreeRepoFile  *self,
       *out_container = ret_container;
       ret_container = NULL;
     }
-  ot_clear_gvariant (&ret_container);
-  ot_clear_gvariant (&files_variant);
-  ot_clear_gvariant (&dirs_variant);
+  g_clear_pointer (&ret_container, (GDestroyNotify) g_variant_unref);
+  g_clear_pointer (&files_variant, (GDestroyNotify) g_variant_unref);
+  g_clear_pointer (&dirs_variant, (GDestroyNotify) g_variant_unref);
   return i;
 }
 
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index db24820..7590b29 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -2802,7 +2802,7 @@ stage_directory_to_mtree_internal (OstreeRepo           *self,
 
                       if (!(modifier && modifier->skip_xattrs))
                         {
-                          ot_clear_gvariant (&xattrs);
+                          g_clear_pointer (&xattrs, (GDestroyNotify) g_variant_unref);
                           if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error))
                             goto out;
                         }
@@ -3751,7 +3751,7 @@ find_object_in_packs (OstreeRepo        *self,
       const char *pack_checksum = index_checksums->pdata[i];
       guint64 offset;
 
-      ot_clear_gvariant (&index_variant);
+      g_clear_pointer (&index_variant, (GDestroyNotify) g_variant_unref);
       if (!ostree_repo_load_pack_index (self, pack_checksum, is_meta, &index_variant,
                                         cancellable, error))
         goto out;
@@ -4549,7 +4549,7 @@ ostree_repo_checkout_tree_async (OstreeRepo               *self,
                                  cancellable, error))
     goto out;
 
-  ot_clear_gvariant (&xattrs);
+  g_clear_pointer (&xattrs, (GDestroyNotify) g_variant_unref);
 
   dir_enum = g_file_enumerate_children ((GFile*)checkout_data->source,
                                         OSTREE_GIO_FAST_QUERYINFO, 
diff --git a/src/libostree/ostree-traverse.c b/src/libostree/ostree-traverse.c
index 43bdfaa..2cc4de5 100644
--- a/src/libostree/ostree-traverse.c
+++ b/src/libostree/ostree-traverse.c
@@ -76,7 +76,7 @@ traverse_dirtree_internal (OstreeRepo      *repo,
         {
           const char *filename;
       
-          ot_clear_gvariant (&csum_v);
+          g_clear_pointer (&csum_v, (GDestroyNotify) g_variant_unref);
           g_variant_get_child (files_variant, i, "(&s ay)", &filename, &csum_v);
           g_free (tmp_checksum);
           tmp_checksum = ostree_checksum_from_bytes_v (csum_v);
@@ -91,8 +91,8 @@ traverse_dirtree_internal (OstreeRepo      *repo,
         {
           const char *dirname;
       
-          ot_clear_gvariant (&content_csum_v);
-          ot_clear_gvariant (&metadata_csum_v);
+          g_clear_pointer (&content_csum_v, (GDestroyNotify) g_variant_unref);
+          g_clear_pointer (&metadata_csum_v, (GDestroyNotify) g_variant_unref);
           g_variant_get_child (dirs_variant, i, "(&s ay@ay)",
                                &dirname, &content_csum_v, &metadata_csum_v);
       
diff --git a/src/libotutil/ot-variant-utils.h b/src/libotutil/ot-variant-utils.h
index f03325b..6ab3dcb 100644
--- a/src/libotutil/ot-variant-utils.h
+++ b/src/libotutil/ot-variant-utils.h
@@ -27,12 +27,6 @@
 
 G_BEGIN_DECLS
 
-#define ot_clear_gvariant(a_v) do { \
-  if (*a_v)                         \
-    g_variant_unref (*a_v);         \
-  *a_v = NULL;                      \
-  } while (0);
-
 #define ot_clear_ptrarray(a_v) do { \
   if (*a_v)                         \
     g_ptr_array_unref (*a_v);         \
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index 04f8011..bfb78b9 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -208,13 +208,13 @@ fsck_reachable_objects_from_commits (OtFsckData            *data,
 
       g_clear_object (&input);
       g_clear_object (&file_info);
-      ot_clear_gvariant (&xattrs);
+      g_clear_pointer (&xattrs, (GDestroyNotify) g_variant_unref);
 
       if (objtype == OSTREE_OBJECT_TYPE_COMMIT
           || objtype == OSTREE_OBJECT_TYPE_DIR_TREE 
           || objtype == OSTREE_OBJECT_TYPE_DIR_META)
         {
-          ot_clear_gvariant (&metadata);
+          g_clear_pointer (&metadata, (GDestroyNotify) g_variant_unref);
           if (!ostree_repo_load_variant (data->repo, objtype,
                                          checksum, &metadata, error))
             {
diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c
index b9bfa40..e352305 100644
--- a/src/ostree/ot-builtin-log.c
+++ b/src/ostree/ot-builtin-log.c
@@ -83,15 +83,15 @@ ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error)
       GVariant *commit_metadata = NULL;
       char *formatted_metadata = NULL;
       
-      ot_clear_gvariant (&commit);
+      g_clear_pointer (&commit, (GDestroyNotify) g_variant_unref);
       if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &commit, error))
         goto out;
 
       /* Ignore commit metadata for now */
-      ot_clear_gvariant (&commit_metadata);
-      ot_clear_gvariant (&parent_csum_v);
-      ot_clear_gvariant (&content_csum_v);
-      ot_clear_gvariant (&metadata_csum_v);
+      g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
+      g_clear_pointer (&parent_csum_v, (GDestroyNotify) g_variant_unref);
+      g_clear_pointer (&content_csum_v, (GDestroyNotify) g_variant_unref);
+      g_clear_pointer (&metadata_csum_v, (GDestroyNotify) g_variant_unref);
       g_variant_get (commit, "(@a{sv} ay@a(say)&s&st ay@ay)",
                      &commit_metadata, &parent_csum_v, NULL, &subject, &body,
                      &timestamp, &content_csum_v, &metadata_csum_v);
@@ -101,7 +101,7 @@ ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error)
       g_date_time_unref (time_obj);
       time_obj = NULL;
 
-      ot_clear_gvariant (&commit_metadata);
+      g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
       formatted = g_strdup_printf ("commit %s\nSubject: %s\nDate: %s\nMetadata: %s\n\n",
                                    resolved_rev, subject, formatted_date, formatted_metadata);
       g_free (formatted_metadata);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]