tree-wide: Use GLib autocleanups for libarchive
Define typedefs for read/write archives, and use the GLib autocleanups for them. Prep for updating libglnx to drop its custom autocleanup macros. Closes: #1042 Approved by: jlebon
This commit is contained in:
parent
ded6417aee
commit
40b41d2cc9
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include "libglnx.h"
|
#include "libglnx.h"
|
||||||
#ifdef HAVE_LIBARCHIVE
|
#ifdef HAVE_LIBARCHIVE
|
||||||
|
|
@ -32,14 +34,10 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#ifdef HAVE_LIBARCHIVE
|
#ifdef HAVE_LIBARCHIVE
|
||||||
GLNX_DEFINE_CLEANUP_FUNCTION (void *, flatpak_local_free_write_archive, archive_write_free)
|
typedef struct archive OtAutoArchiveWrite;
|
||||||
#define ot_cleanup_write_archive __attribute__((cleanup (flatpak_local_free_write_archive)))
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OtAutoArchiveWrite, archive_write_free)
|
||||||
|
typedef struct archive OtAutoArchiveRead;
|
||||||
GLNX_DEFINE_CLEANUP_FUNCTION (void *, flatpak_local_free_read_archive, archive_read_free)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OtAutoArchiveRead, archive_read_free)
|
||||||
#define ot_cleanup_read_archive __attribute__((cleanup (flatpak_local_free_read_archive)))
|
|
||||||
#else
|
|
||||||
#define ot_cleanup_write_archive
|
|
||||||
#define ot_cleanup_read_archive
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
||||||
|
|
@ -900,7 +900,7 @@ ostree_repo_write_archive_to_mtree (OstreeRepo *self,
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBARCHIVE
|
#ifdef HAVE_LIBARCHIVE
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
|
|
||||||
#ifdef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL
|
#ifdef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
|
||||||
g_autoptr(GFile) subtree = NULL;
|
g_autoptr(GFile) subtree = NULL;
|
||||||
g_autofree char *commit = NULL;
|
g_autofree char *commit = NULL;
|
||||||
g_autoptr(GVariant) commit_data = NULL;
|
g_autoptr(GVariant) commit_data = NULL;
|
||||||
ot_cleanup_write_archive struct archive *a = NULL;
|
g_autoptr(OtAutoArchiveWrite) a = NULL;
|
||||||
OstreeRepoExportArchiveOptions opts = { 0, };
|
OstreeRepoExportArchiveOptions opts = { 0, };
|
||||||
|
|
||||||
context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
|
context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ static void
|
||||||
test_data_init (TestData *td)
|
test_data_init (TestData *td)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ot_cleanup_write_archive struct archive *a = archive_write_new ();
|
g_autoptr(OtAutoArchiveWrite) a = archive_write_new ();
|
||||||
struct archive_entry *ae;
|
struct archive_entry *ae;
|
||||||
uid_t uid = getuid ();
|
uid_t uid = getuid ();
|
||||||
gid_t gid = getgid ();
|
gid_t gid = getgid ();
|
||||||
|
|
@ -165,7 +165,7 @@ test_libarchive_noautocreate_empty (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ test_libarchive_autocreate_empty (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ test_libarchive_error_device_file (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||||
|
|
||||||
|
|
@ -270,7 +270,7 @@ test_libarchive_ignore_device_file (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
|
|
||||||
if (skip_if_no_xattr (td))
|
if (skip_if_no_xattr (td))
|
||||||
|
|
@ -332,7 +332,7 @@ test_libarchive_ostree_convention (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
|
|
||||||
if (skip_if_no_xattr (td))
|
if (skip_if_no_xattr (td))
|
||||||
|
|
@ -374,7 +374,7 @@ test_libarchive_xattr_callback (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0 };
|
OstreeRepoImportArchiveOptions opts = { 0 };
|
||||||
OstreeRepoCommitModifier *modifier = NULL;
|
OstreeRepoCommitModifier *modifier = NULL;
|
||||||
char buf[7] = { 0 };
|
char buf[7] = { 0 };
|
||||||
|
|
@ -429,7 +429,7 @@ static void
|
||||||
entry_pathname_test_helper (gconstpointer data, gboolean on)
|
entry_pathname_test_helper (gconstpointer data, gboolean on)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data; GError *error = NULL;
|
TestData *td = (void*)data; GError *error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
OstreeRepoCommitModifier *modifier = NULL;
|
OstreeRepoCommitModifier *modifier = NULL;
|
||||||
gboolean met_etc_file = FALSE;
|
gboolean met_etc_file = FALSE;
|
||||||
|
|
@ -491,7 +491,7 @@ test_libarchive_selinux (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ot_cleanup_read_archive struct archive *a = archive_read_new ();
|
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0 };
|
OstreeRepoImportArchiveOptions opts = { 0 };
|
||||||
glnx_unref_object OstreeSePolicy *sepol = NULL;
|
glnx_unref_object OstreeSePolicy *sepol = NULL;
|
||||||
OstreeRepoCommitModifier *modifier = NULL;
|
OstreeRepoCommitModifier *modifier = NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue