core: Fix xattr API to conform to coding style

This commit is contained in:
Colin Walters 2012-04-09 15:09:27 -04:00
parent 3c39a5bfa7
commit 72398ab62c
5 changed files with 29 additions and 19 deletions

View File

@ -151,13 +151,17 @@ read_xattr_name_array (const char *path,
return ret; return ret;
} }
GVariant * gboolean
ostree_get_xattrs_for_file (GFile *f, ostree_get_xattrs_for_file (GFile *f,
GError **error) GVariant **out_xattrs,
GCancellable *cancellable,
GError **error)
{ {
gboolean ret = FALSE;
const char *path; const char *path;
GVariant *ret = NULL; GVariant *ret_xattrs = NULL;
GVariantBuilder builder; GVariantBuilder builder;
gboolean builder_initialized = FALSE;
char *xattr_names = NULL; char *xattr_names = NULL;
char *xattr_names_canonical = NULL; char *xattr_names_canonical = NULL;
ssize_t bytes_read; ssize_t bytes_read;
@ -165,6 +169,7 @@ ostree_get_xattrs_for_file (GFile *f,
path = ot_gfile_get_path_cached (f); path = ot_gfile_get_path_cached (f);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
builder_initialized = TRUE;
bytes_read = llistxattr (path, NULL, 0); bytes_read = llistxattr (path, NULL, 0);
@ -190,10 +195,13 @@ ostree_get_xattrs_for_file (GFile *f,
goto out; goto out;
} }
ret = g_variant_builder_end (&builder); ret_xattrs = g_variant_builder_end (&builder);
g_variant_ref_sink (ret); g_variant_ref_sink (ret_xattrs);
ret = TRUE;
ot_transfer_out_value (out_xattrs, &ret_xattrs);
out: out:
if (!ret) if (!builder_initialized)
g_variant_builder_clear (&builder); g_variant_builder_clear (&builder);
g_free (xattr_names); g_free (xattr_names);
g_free (xattr_names_canonical); g_free (xattr_names_canonical);
@ -316,8 +324,7 @@ ostree_checksum_file (GFile *f,
if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE) if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE)
{ {
xattrs = ostree_get_xattrs_for_file (f, error); if (!ostree_get_xattrs_for_file (f, &xattrs, cancellable, error))
if (!xattrs)
goto out; goto out;
} }

View File

@ -178,8 +178,10 @@ void ostree_object_from_string (const char *str,
char *ostree_get_relative_object_path (const char *checksum, char *ostree_get_relative_object_path (const char *checksum,
OstreeObjectType type); OstreeObjectType type);
GVariant *ostree_get_xattrs_for_file (GFile *f, gboolean ostree_get_xattrs_for_file (GFile *f,
GError **error); GVariant **out_xattrs,
GCancellable *cancellable,
GError **error);
GVariant *ostree_wrap_metadata_variant (OstreeObjectType type, GVariant *metadata); GVariant *ostree_wrap_metadata_variant (OstreeObjectType type, GVariant *metadata);

View File

@ -317,7 +317,8 @@ ostree_repo_file_get_xattrs (OstreeRepoFile *self,
else else
{ {
local_file = ostree_repo_file_nontree_get_local (self); 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; ret = TRUE;

View File

@ -2324,8 +2324,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
{ {
if (!(modifier && modifier->skip_xattrs)) if (!(modifier && modifier->skip_xattrs))
{ {
xattrs = ostree_get_xattrs_for_file (dir, error); if (!ostree_get_xattrs_for_file (dir, &xattrs, cancellable, error))
if (!xattrs)
goto out; goto out;
} }
@ -2394,8 +2393,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
if (!(modifier && modifier->skip_xattrs)) if (!(modifier && modifier->skip_xattrs))
{ {
xattrs = ostree_get_xattrs_for_file (child, error); if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error))
if (!xattrs)
goto out; goto out;
} }
@ -3239,8 +3237,7 @@ ostree_repo_load_file (OstreeRepo *self,
} }
if (out_xattrs) if (out_xattrs)
{ {
ret_xattrs = ostree_get_xattrs_for_file (content_loose_path, error); if (!ostree_get_xattrs_for_file (content_loose_path, &ret_xattrs, cancellable,error))
if (!ret_xattrs)
goto out; goto out;
} }
} }

View File

@ -121,7 +121,10 @@ import_loose_object (OtLocalCloneData *data,
goto out; goto out;
if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE) 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) if (objtype == OSTREE_OBJECT_TYPE_ARCHIVED_FILE_CONTENT)
; ;