[ostree] core: Fix xattr API to conform to coding style



commit 72398ab62ce6461de9cafa7fb6450d49b1433b6e
Author: Colin Walters <walters verbum org>
Date:   Mon Apr 9 15:09:27 2012 -0400

    core: Fix xattr API to conform to coding style

 src/libostree/ostree-core.c         |   25 ++++++++++++++++---------
 src/libostree/ostree-core.h         |    6 ++++--
 src/libostree/ostree-repo-file.c    |    3 ++-
 src/libostree/ostree-repo.c         |    9 +++------
 src/ostree/ot-builtin-local-clone.c |    5 ++++-
 5 files changed, 29 insertions(+), 19 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 947bc6d..f288726 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -151,13 +151,17 @@ read_xattr_name_array (const char *path,
   return ret;
 }
 
-GVariant *
-ostree_get_xattrs_for_file (GFile      *f,
-                            GError    **error)
+gboolean
+ostree_get_xattrs_for_file (GFile         *f,
+                            GVariant     **out_xattrs,
+                            GCancellable  *cancellable,
+                            GError       **error)
 {
+  gboolean ret = FALSE;
   const char *path;
-  GVariant *ret = NULL;
+  GVariant *ret_xattrs = NULL;
   GVariantBuilder builder;
+  gboolean builder_initialized = FALSE;
   char *xattr_names = NULL;
   char *xattr_names_canonical = NULL;
   ssize_t bytes_read;
@@ -165,6 +169,7 @@ ostree_get_xattrs_for_file (GFile      *f,
   path = ot_gfile_get_path_cached (f);
 
   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
+  builder_initialized = TRUE;
 
   bytes_read = llistxattr (path, NULL, 0);
 
@@ -190,10 +195,13 @@ ostree_get_xattrs_for_file (GFile      *f,
         goto out;
     }
 
-  ret = g_variant_builder_end (&builder);
-  g_variant_ref_sink (ret);
+  ret_xattrs = g_variant_builder_end (&builder);
+  g_variant_ref_sink (ret_xattrs);
+  
+  ret = TRUE;
+  ot_transfer_out_value (out_xattrs, &ret_xattrs);
  out:
-  if (!ret)
+  if (!builder_initialized)
     g_variant_builder_clear (&builder);
   g_free (xattr_names);
   g_free (xattr_names_canonical);
@@ -316,8 +324,7 @@ ostree_checksum_file (GFile            *f,
 
   if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE)
     {
-      xattrs = ostree_get_xattrs_for_file (f, error);
-      if (!xattrs)
+      if (!ostree_get_xattrs_for_file (f, &xattrs, cancellable, error))
         goto out;
     }
 
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 1df8a6a..5c578d4 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -178,8 +178,10 @@ void ostree_object_from_string (const char *str,
 char *ostree_get_relative_object_path (const char        *checksum,
                                        OstreeObjectType   type);
 
-GVariant *ostree_get_xattrs_for_file (GFile       *f,
-                                      GError     **error);
+gboolean ostree_get_xattrs_for_file (GFile         *f,
+                                     GVariant     **out_xattrs,
+                                     GCancellable  *cancellable,
+                                     GError       **error);
 
 GVariant *ostree_wrap_metadata_variant (OstreeObjectType type, GVariant *metadata);
 
diff --git a/src/libostree/ostree-repo-file.c b/src/libostree/ostree-repo-file.c
index ac4b129..d81adbe 100644
--- a/src/libostree/ostree-repo-file.c
+++ b/src/libostree/ostree-repo-file.c
@@ -317,7 +317,8 @@ ostree_repo_file_get_xattrs (OstreeRepoFile  *self,
   else
     {
       local_file = ostree_repo_file_nontree_get_local (self);
-      ret_xattrs = ostree_get_xattrs_for_file (local_file, error);
+      if (!ostree_get_xattrs_for_file (local_file, &ret_xattrs, cancellable, error))
+        goto out;
     }
 
   ret = TRUE;
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 651a44f..84b8a23 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -2324,8 +2324,7 @@ stage_directory_to_mtree_internal (OstreeRepo           *self,
         {
           if (!(modifier && modifier->skip_xattrs))
             {
-              xattrs = ostree_get_xattrs_for_file (dir, error);
-              if (!xattrs)
+              if (!ostree_get_xattrs_for_file (dir, &xattrs, cancellable, error))
                 goto out;
             }
           
@@ -2394,8 +2393,7 @@ stage_directory_to_mtree_internal (OstreeRepo           *self,
 
                   if (!(modifier && modifier->skip_xattrs))
                     {
-                      xattrs = ostree_get_xattrs_for_file (child, error);
-                      if (!xattrs)
+                      if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error))
                         goto out;
                     }
 
@@ -3239,8 +3237,7 @@ ostree_repo_load_file (OstreeRepo         *self,
         }
       if (out_xattrs)
         {
-          ret_xattrs = ostree_get_xattrs_for_file (content_loose_path, error);
-          if (!ret_xattrs)
+          if (!ostree_get_xattrs_for_file (content_loose_path, &ret_xattrs, cancellable,error))
             goto out;
         }
     }
diff --git a/src/ostree/ot-builtin-local-clone.c b/src/ostree/ot-builtin-local-clone.c
index 1c9a3d0..7f2d5aa 100644
--- a/src/ostree/ot-builtin-local-clone.c
+++ b/src/ostree/ot-builtin-local-clone.c
@@ -121,7 +121,10 @@ import_loose_object (OtLocalCloneData *data,
     goto out;
 
   if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE)
-    xattrs = ostree_get_xattrs_for_file (objfile, error);
+    {
+      if (!ostree_get_xattrs_for_file (objfile, &xattrs, cancellable, error))
+        goto out;
+    }
   
   if (objtype == OSTREE_OBJECT_TYPE_ARCHIVED_FILE_CONTENT)
     ;



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