Merge pull request #2551 from q66/guri

lib: bump glib requirement to 2.66 and port to GUri
This commit is contained in:
Colin Walters 2022-03-14 08:52:51 -04:00 committed by GitHub
commit 6ba254ab11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 266 additions and 1957 deletions

View File

@ -221,8 +221,6 @@ endif
if USE_CURL
libostree_1_la_SOURCES += src/libostree/ostree-fetcher-curl.c \
src/libostree/ostree-soup-uri.h src/libostree/ostree-soup-uri.c \
src/libostree/ostree-soup-form.c \
$(NULL)
libostree_1_la_CFLAGS += $(OT_DEP_CURL_CFLAGS)
libostree_1_la_LIBADD += $(OT_DEP_CURL_LIBS)
@ -231,13 +229,6 @@ if USE_LIBSOUP
libostree_1_la_SOURCES += src/libostree/ostree-fetcher-soup.c
libostree_1_la_CFLAGS += $(OT_INTERNAL_SOUP_CFLAGS)
libostree_1_la_LIBADD += $(OT_INTERNAL_SOUP_LIBS)
else
if USE_AVAHI
libostree_1_la_SOURCES += src/libostree/ostree-soup-uri.h \
src/libostree/ostree-soup-uri.c \
src/libostree/ostree-soup-form.c \
$(NULL)
endif
endif
endif

View File

@ -29,7 +29,7 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
-DOSTREE_COMPILATION \
-DG_LOG_DOMAIN=\"OSTree\" \
-DOSTREE_GITREV='"$(OSTREE_GITREV)"' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44 '-DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,50)' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_66 '-DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,70)' \
-DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 '-DSOUP_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,48)'
# For strict aliasing, see https://bugzilla.gnome.org/show_bug.cgi?id=791622
AM_CFLAGS += -std=gnu99 -fno-strict-aliasing $(WARN_CFLAGS)

View File

@ -113,7 +113,7 @@ AM_PATH_GLIB_2_0(,,AC_MSG_ERROR([GLib not found]))
dnl When bumping the gio-unix-2.0 dependency (or glib-2.0 in general),
dnl remember to bump GLIB_VERSION_MIN_REQUIRED and
dnl GLIB_VERSION_MAX_ALLOWED in Makefile.am
GIO_DEPENDENCY="gio-unix-2.0 >= 2.44.0"
GIO_DEPENDENCY="gio-unix-2.0 >= 2.66.0"
PKG_CHECK_MODULES(OT_DEP_GIO_UNIX, $GIO_DEPENDENCY)
dnl 5.1.0 is an arbitrary version here

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -26,13 +27,13 @@ enum {
PROP_STREAMS
};
G_DEFINE_TYPE (OstreeChainInputStream, ostree_chain_input_stream, G_TYPE_INPUT_STREAM)
struct _OstreeChainInputStreamPrivate {
GPtrArray *streams;
guint index;
};
G_DEFINE_TYPE_WITH_PRIVATE (OstreeChainInputStream, ostree_chain_input_stream, G_TYPE_INPUT_STREAM)
static void ostree_chain_input_stream_set_property (GObject *object,
guint prop_id,
const GValue *value,
@ -56,8 +57,6 @@ ostree_chain_input_stream_class_init (OstreeChainInputStreamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
g_type_class_add_private (klass, sizeof (OstreeChainInputStreamPrivate));
gobject_class->get_property = ostree_chain_input_stream_get_property;
gobject_class->set_property = ostree_chain_input_stream_set_property;
@ -137,9 +136,7 @@ ostree_chain_input_stream_finalize (GObject *object)
static void
ostree_chain_input_stream_init (OstreeChainInputStream *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
OSTREE_TYPE_CHAIN_INPUT_STREAM,
OstreeChainInputStreamPrivate);
self->priv = ostree_chain_input_stream_get_instance_private (self);
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -26,12 +27,12 @@ enum {
PROP_CHECKSUM
};
G_DEFINE_TYPE (OstreeChecksumInputStream, ostree_checksum_input_stream, G_TYPE_FILTER_INPUT_STREAM)
struct _OstreeChecksumInputStreamPrivate {
GChecksum *checksum;
};
G_DEFINE_TYPE_WITH_PRIVATE (OstreeChecksumInputStream, ostree_checksum_input_stream, G_TYPE_FILTER_INPUT_STREAM)
static void ostree_checksum_input_stream_set_property (GObject *object,
guint prop_id,
const GValue *value,
@ -51,8 +52,6 @@ ostree_checksum_input_stream_class_init (OstreeChecksumInputStreamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
g_type_class_add_private (klass, sizeof (OstreeChecksumInputStreamPrivate));
gobject_class->get_property = ostree_checksum_input_stream_get_property;
gobject_class->set_property = ostree_checksum_input_stream_set_property;
@ -118,10 +117,7 @@ ostree_checksum_input_stream_get_property (GObject *object,
static void
ostree_checksum_input_stream_init (OstreeChecksumInputStream *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
OSTREE_TYPE_CHECKSUM_INPUT_STREAM,
OstreeChecksumInputStreamPrivate);
self->priv = ostree_checksum_input_stream_get_instance_private (self);
}
OstreeChecksumInputStream *

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -1031,19 +1032,22 @@ typedef struct {
} ChecksumFileAsyncData;
static void
checksum_file_async_thread (GSimpleAsyncResult *res,
checksum_file_async_thread (GTask *task,
GObject *object,
gpointer datap,
GCancellable *cancellable)
{
GError *error = NULL;
ChecksumFileAsyncData *data;
ChecksumFileAsyncData *data = datap;
guchar *csum = NULL;
data = g_simple_async_result_get_op_res_gpointer (res);
if (!ostree_checksum_file (data->f, data->objtype, &csum, cancellable, &error))
g_simple_async_result_take_error (res, error);
g_task_return_error (task, error);
else
data->csum = csum;
{
data->csum = csum;
g_task_return_pointer (task, data, NULL);
}
}
static void
@ -1076,18 +1080,18 @@ ostree_checksum_file_async (GFile *f,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *res;
g_autoptr(GTask) task = NULL;
ChecksumFileAsyncData *data;
data = g_new0 (ChecksumFileAsyncData, 1);
data->f = g_object_ref (f);
data->objtype = objtype;
res = g_simple_async_result_new (G_OBJECT (f), callback, user_data, ostree_checksum_file_async);
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)checksum_file_async_data_free);
g_simple_async_result_run_in_thread (res, checksum_file_async_thread, io_priority, cancellable);
g_object_unref (res);
task = g_task_new (G_OBJECT (f), cancellable, callback, user_data);
g_task_set_task_data (task, data, (GDestroyNotify)checksum_file_async_data_free);
g_task_set_priority (task, io_priority);
g_task_set_source_tag (task, ostree_checksum_file_async);
g_task_run_in_thread (task, (GTaskThreadFunc)checksum_file_async_thread);
}
/**
@ -1106,15 +1110,19 @@ ostree_checksum_file_async_finish (GFile *f,
guchar **out_csum,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
ChecksumFileAsyncData *data;
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == ostree_checksum_file_async);
g_return_val_if_fail (G_IS_FILE (f), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, f), FALSE);
g_return_val_if_fail (g_async_result_is_tagged (result, ostree_checksum_file_async), FALSE);
if (g_simple_async_result_propagate_error (simple, error))
data = g_task_propagate_pointer (G_TASK (result), error);
if (data == NULL)
return FALSE;
data = g_simple_async_result_get_op_res_gpointer (simple);
/* Transfer ownership */
*out_csum = data->csum;
data->csum = NULL;

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -50,8 +51,6 @@
#include "ostree-repo-private.h"
#include "otutil.h"
#include "ostree-soup-uri.h"
typedef struct FetcherRequest FetcherRequest;
typedef struct SockInfo SockInfo;
@ -183,13 +182,13 @@ _ostree_fetcher_finalize (GObject *object)
g_free (self->cookie_jar_path);
g_free (self->proxy);
g_assert_cmpint (g_hash_table_size (self->outstanding_requests), ==, 0);
g_clear_pointer (&self->extra_headers, (GDestroyNotify)curl_slist_free_all);
g_clear_pointer (&self->extra_headers, curl_slist_free_all);
g_hash_table_unref (self->outstanding_requests);
g_hash_table_unref (self->sockets);
g_clear_pointer (&self->timer_event, (GDestroyNotify)destroy_and_unref_source);
g_clear_pointer (&self->timer_event, destroy_and_unref_source);
if (self->mainctx)
g_main_context_unref (self->mainctx);
g_clear_pointer (&self->custom_user_agent, (GDestroyNotify)g_free);
g_clear_pointer (&self->custom_user_agent, g_free);
G_OBJECT_CLASS (_ostree_fetcher_parent_class)->finalize (object);
}
@ -266,11 +265,11 @@ destroy_and_unref_source (GSource *source)
}
static char *
request_get_uri (FetcherRequest *req, SoupURI *baseuri)
request_get_uri (FetcherRequest *req, GUri *baseuri)
{
if (!req->filename)
return soup_uri_to_string (baseuri, FALSE);
{ g_autofree char *uristr = soup_uri_to_string (baseuri, FALSE);
return g_uri_to_string_partial (baseuri, G_URI_HIDE_PASSWORD);
{ g_autofree char *uristr = g_uri_to_string_partial (baseuri, G_URI_HIDE_PASSWORD);
return g_build_filename (uristr, req->filename, NULL);
}
}
@ -424,7 +423,7 @@ static gboolean
timer_cb (gpointer data)
{
OstreeFetcher *fetcher = data;
g_clear_pointer (&fetcher->timer_event, (GDestroyNotify)destroy_and_unref_source);
g_clear_pointer (&fetcher->timer_event, destroy_and_unref_source);
(void)curl_multi_socket_action (fetcher->multi, CURL_SOCKET_TIMEOUT, 0, &fetcher->curl_running);
check_multi_info (fetcher);
@ -437,7 +436,7 @@ update_timeout_cb (CURLM *multi, long timeout_ms, void *userp)
{
OstreeFetcher *fetcher = userp;
g_clear_pointer (&fetcher->timer_event, (GDestroyNotify)destroy_and_unref_source);
g_clear_pointer (&fetcher->timer_event, destroy_and_unref_source);
if (timeout_ms != -1)
{
@ -479,7 +478,7 @@ sock_unref (SockInfo *f)
return;
if (--f->refcount != 0)
return;
g_clear_pointer (&f->ch, (GDestroyNotify)destroy_and_unref_source);
g_clear_pointer (&f->ch, destroy_and_unref_source);
g_free (f);
}
@ -492,7 +491,7 @@ setsock (SockInfo*f, curl_socket_t s, int act, OstreeFetcher *fetcher)
f->sockfd = s;
f->action = act;
g_clear_pointer (&f->ch, (GDestroyNotify)destroy_and_unref_source);
g_clear_pointer (&f->ch, destroy_and_unref_source);
/* TODO - investigate new g_source_modify_unix_fd() so changing the poll
* flags involves less allocation.
*/
@ -648,7 +647,7 @@ request_unref (FetcherRequest *req)
g_string_free (req->output_buf, TRUE);
g_free (req->if_none_match);
g_free (req->out_etag);
g_clear_pointer (&req->req_headers, (GDestroyNotify)curl_slist_free_all);
g_clear_pointer (&req->req_headers, curl_slist_free_all);
curl_easy_cleanup (req->easy);
g_free (req);
@ -705,7 +704,7 @@ _ostree_fetcher_set_extra_headers (OstreeFetcher *self,
const char *key;
const char *value;
g_clear_pointer (&self->extra_headers, (GDestroyNotify)curl_slist_free_all);
g_clear_pointer (&self->extra_headers, curl_slist_free_all);
g_variant_iter_init (&viter, extra_headers);
while (g_variant_iter_loop (&viter, "(&s&s)", &key, &value))
@ -719,7 +718,7 @@ void
_ostree_fetcher_set_extra_user_agent (OstreeFetcher *self,
const char *extra_user_agent)
{
g_clear_pointer (&self->custom_user_agent, (GDestroyNotify)g_free);
g_clear_pointer (&self->custom_user_agent, g_free);
if (extra_user_agent)
{
self->custom_user_agent =
@ -763,7 +762,7 @@ initiate_next_curl_request (FetcherRequest *req,
g_assert_cmpint (req->idx, <, req->mirrorlist->len);
SoupURI *baseuri = req->mirrorlist->pdata[req->idx];
GUri *baseuri = req->mirrorlist->pdata[req->idx];
{ g_autofree char *uri = request_get_uri (req, baseuri);
curl_easy_setopt (req->easy, CURLOPT_URL, uri);
}
@ -842,9 +841,9 @@ initiate_next_curl_request (FetcherRequest *req,
curl_easy_setopt (req->easy, CURLOPT_ACCEPT_ENCODING, "");
/* If we have e.g. basic auth in the URL string, let's honor that */
const char *username = soup_uri_get_user (baseuri);
const char *username = g_uri_get_user (baseuri);
curl_easy_setopt (req->easy, CURLOPT_USERNAME, username);
const char *password = soup_uri_get_password (baseuri);
const char *password = g_uri_get_password (baseuri);
curl_easy_setopt (req->easy, CURLOPT_PASSWORD, password);
/* We should only speak HTTP; TODO: only enable file if specified */

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -153,7 +154,7 @@ thread_closure_unref (ThreadClosure *thread_closure)
g_clear_pointer (&thread_closure->main_context, g_main_context_unref);
g_clear_pointer (&thread_closure->extra_headers, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&thread_closure->extra_headers, g_variant_unref);
g_clear_pointer (&thread_closure->output_stream_set, g_hash_table_unref);
g_mutex_clear (&thread_closure->output_stream_set_lock);
@ -329,7 +330,7 @@ session_thread_set_headers_cb (ThreadClosure *thread_closure,
{
GVariant *headers = data;
g_clear_pointer (&thread_closure->extra_headers, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&thread_closure->extra_headers, g_variant_unref);
thread_closure->extra_headers = g_variant_ref (headers);
}
@ -431,11 +432,15 @@ create_pending_soup_request (OstreeFetcherPendingURI *pending,
next_mirror = g_ptr_array_index (pending->mirrorlist, pending->mirrorlist_idx);
if (pending->filename)
uri = _ostree_fetcher_uri_new_subpath (next_mirror, pending->filename);
if (!uri)
uri = (OstreeFetcherURI*)g_uri_ref ((GUri*)next_mirror);
g_clear_object (&pending->request);
pending->request = soup_session_request_uri (pending->thread_closure->session,
(SoupURI*)(uri ? uri : next_mirror), error);
{
g_autofree gchar *uri_str = g_uri_to_string ((GUri*)uri);
pending->request = soup_session_request (pending->thread_closure->session, uri_str, error);
}
/* Add caching headers. */
if (SOUP_IS_REQUEST_HTTP (pending->request) && pending->if_none_match != NULL)

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011,2017 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -21,15 +22,7 @@
#include "config.h"
#ifdef HAVE_LIBCURL
#include "ostree-soup-uri.h"
#else
#define LIBSOUP_USE_UNSTABLE_REQUEST_API
#include <libsoup/soup.h>
#include <libsoup/soup-requester.h>
#include <libsoup/soup-request-http.h>
#endif
#include <glib.h>
#include "ostree-fetcher.h"
@ -39,21 +32,52 @@ void
_ostree_fetcher_uri_free (OstreeFetcherURI *uri)
{
if (uri)
soup_uri_free ((SoupURI*)uri);
g_uri_unref ((GUri*)uri);
}
OstreeFetcherURI *
_ostree_fetcher_uri_parse (const char *str,
GError **error)
{
SoupURI *soupuri = soup_uri_new (str);
if (soupuri == NULL)
GUri *uri = NULL;
#if GLIB_CHECK_VERSION(2, 68, 0)
uri = g_uri_parse (str, G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED | G_URI_FLAGS_SCHEME_NORMALIZE, error);
#else
/* perform manual scheme normalization for older glib */
uri = g_uri_parse (str, G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED, error);
if (uri)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to parse uri: %s", str);
return NULL;
GUri *nuri = NULL;
switch (g_uri_get_port (uri))
{
case 21:
if (!strcmp (g_uri_get_scheme (uri), "ftp"))
break;
return (OstreeFetcherURI*)uri;
case 80:
if (!strcmp (g_uri_get_scheme (uri), "http"))
break;
return (OstreeFetcherURI*)uri;
case 443:
if (!strcmp (g_uri_get_scheme (uri), "https"))
break;
return (OstreeFetcherURI*)uri;
default:
return (OstreeFetcherURI*)uri;
}
nuri = g_uri_build_with_user (g_uri_get_flags (uri), "http",
g_uri_get_user (uri),
g_uri_get_password (uri),
NULL,
g_uri_get_host (uri), -1,
g_uri_get_path (uri),
g_uri_get_query (uri),
g_uri_get_fragment (uri));
g_uri_unref (uri);
uri = nuri;
}
return (OstreeFetcherURI*)soupuri;
#endif
return (OstreeFetcherURI*)uri;
}
static OstreeFetcherURI *
@ -61,21 +85,31 @@ _ostree_fetcher_uri_new_path_internal (OstreeFetcherURI *uri,
gboolean extend,
const char *path)
{
SoupURI *newuri = soup_uri_copy ((SoupURI*)uri);
GUri *guri = (GUri*)uri;
const char *opath = g_uri_get_path (guri);
g_autofree char *newpath = NULL;
if (path)
{
if (extend)
{
const char *origpath = soup_uri_get_path ((SoupURI*)uri);
g_autofree char *newpath = g_build_filename (origpath, path, NULL);
soup_uri_set_path (newuri, newpath);
newpath = g_build_filename (opath, path, NULL);
opath = newpath;
}
else
{
soup_uri_set_path (newuri, path);
opath = path;
}
}
return (OstreeFetcherURI*)newuri;
return (OstreeFetcherURI*)g_uri_build_with_user (g_uri_get_flags (guri),
g_uri_get_scheme (guri),
g_uri_get_user (guri),
g_uri_get_password (guri),
NULL,
g_uri_get_host (guri),
g_uri_get_port (guri),
opath,
g_uri_get_query (guri),
g_uri_get_fragment (guri));
}
OstreeFetcherURI *
@ -101,19 +135,19 @@ _ostree_fetcher_uri_clone (OstreeFetcherURI *uri)
char *
_ostree_fetcher_uri_get_scheme (OstreeFetcherURI *uri)
{
return g_strdup (soup_uri_get_scheme ((SoupURI*)uri));
return g_strdup (g_uri_get_scheme ((GUri*)uri));
}
char *
_ostree_fetcher_uri_get_path (OstreeFetcherURI *uri)
{
return g_strdup (soup_uri_get_path ((SoupURI*)uri));
return g_strdup (g_uri_get_path ((GUri*)uri));
}
char *
_ostree_fetcher_uri_to_string (OstreeFetcherURI *uri)
{
return soup_uri_to_string ((SoupURI*)uri, FALSE);
return g_uri_to_string_partial ((GUri*)uri, G_URI_HIDE_PASSWORD);
}
@ -124,7 +158,7 @@ _ostree_fetcher_uri_to_string (OstreeFetcherURI *uri)
gboolean
_ostree_fetcher_uri_validate (OstreeFetcherURI *uri, GError **error)
{
const char *scheme = soup_uri_get_scheme ((SoupURI*)uri);
const char *scheme = g_uri_get_scheme ((GUri*)uri);
// TODO only allow file if explicitly requested by a higher level
if (!(g_str_equal (scheme, "http") || g_str_equal (scheme, "https") || g_str_equal (scheme, "file")))
{

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -124,7 +125,7 @@ _ostree_fetcher_mirrored_request_to_membuf_once (OstreeFetcher *fe
out:
if (mainctx)
g_main_context_pop_thread_default (mainctx);
g_clear_pointer (&data.result_buf, (GDestroyNotify)g_bytes_unref);
g_clear_pointer (&data.result_buf, g_bytes_unref);
g_clear_pointer (&data.result_etag, g_free);
return ret;
}

View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2013 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -53,7 +54,7 @@ ostree_gpg_verifier_finalize (GObject *object)
g_list_free_full (self->keyrings, g_object_unref);
if (self->key_ascii_files)
g_ptr_array_unref (self->key_ascii_files);
g_clear_pointer (&self->keyring_data, (GDestroyNotify)g_ptr_array_unref);
g_clear_pointer (&self->keyring_data, g_ptr_array_unref);
G_OBJECT_CLASS (_ostree_gpg_verifier_parent_class)->finalize (object);
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -29,12 +30,12 @@ enum {
PROP_ARCHIVE
};
G_DEFINE_TYPE (OstreeLibarchiveInputStream, _ostree_libarchive_input_stream, G_TYPE_INPUT_STREAM)
struct _OstreeLibarchiveInputStreamPrivate {
struct archive *archive;
};
G_DEFINE_TYPE_WITH_PRIVATE (OstreeLibarchiveInputStream, _ostree_libarchive_input_stream, G_TYPE_INPUT_STREAM)
static void ostree_libarchive_input_stream_set_property (GObject *object,
guint prop_id,
const GValue *value,
@ -63,8 +64,6 @@ _ostree_libarchive_input_stream_class_init (OstreeLibarchiveInputStreamClass *kl
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
g_type_class_add_private (klass, sizeof (OstreeLibarchiveInputStreamPrivate));
gobject_class->get_property = ostree_libarchive_input_stream_get_property;
gobject_class->set_property = ostree_libarchive_input_stream_set_property;
@ -132,10 +131,7 @@ ostree_libarchive_input_stream_get_property (GObject *object,
static void
_ostree_libarchive_input_stream_init (OstreeLibarchiveInputStream *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM,
OstreeLibarchiveInputStreamPrivate);
self->priv = _ostree_libarchive_input_stream_get_instance_private (self);
}
GInputStream *

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -66,7 +67,7 @@ _ostree_lzma_compressor_finalize (GObject *object)
OstreeLzmaCompressor *self = OSTREE_LZMA_COMPRESSOR (object);
lzma_end (&self->lstream);
g_clear_pointer (&self->params, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&self->params, g_variant_unref);
G_OBJECT_CLASS (_ostree_lzma_compressor_parent_class)->finalize (object);
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -640,8 +641,8 @@ _ostree_repo_bare_content_cleanup (OstreeRepoBareContent *regwrite)
return;
glnx_tmpfile_clear (&real->tmpf);
ot_checksum_clear (&real->checksum);
g_clear_pointer (&real->expected_checksum, (GDestroyNotify)g_free);
g_clear_pointer (&real->xattrs, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&real->expected_checksum, g_free);
g_clear_pointer (&real->xattrs, g_variant_unref);
real->initialized = FALSE;
}
@ -2584,8 +2585,6 @@ typedef struct {
char *expected_checksum;
GVariant *object;
GCancellable *cancellable;
GSimpleAsyncResult *result;
guchar *result_csum;
} WriteMetadataAsyncData;
@ -2603,19 +2602,21 @@ write_metadata_async_data_free (gpointer user_data)
}
static void
write_metadata_thread (GSimpleAsyncResult *res,
write_metadata_thread (GTask *task,
GObject *object,
gpointer datap,
GCancellable *cancellable)
{
GError *error = NULL;
WriteMetadataAsyncData *data;
WriteMetadataAsyncData *data = datap;
data = g_simple_async_result_get_op_res_gpointer (res);
if (!ostree_repo_write_metadata (data->repo, data->objtype, data->expected_checksum,
data->object,
&data->result_csum,
cancellable, &error))
g_simple_async_result_take_error (res, error);
g_task_return_error (task, error);
else
g_task_return_pointer (task, data, NULL);
}
/**
@ -2640,6 +2641,7 @@ ostree_repo_write_metadata_async (OstreeRepo *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
WriteMetadataAsyncData *asyncdata;
asyncdata = g_new0 (WriteMetadataAsyncData, 1);
@ -2649,14 +2651,10 @@ ostree_repo_write_metadata_async (OstreeRepo *self,
asyncdata->object = g_variant_ref (object);
asyncdata->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
asyncdata->result = g_simple_async_result_new ((GObject*) self,
callback, user_data,
ostree_repo_write_metadata_async);
g_simple_async_result_set_op_res_gpointer (asyncdata->result, asyncdata,
write_metadata_async_data_free);
g_simple_async_result_run_in_thread (asyncdata->result, write_metadata_thread, G_PRIORITY_DEFAULT, cancellable);
g_object_unref (asyncdata->result);
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
g_task_set_task_data (task, asyncdata, write_metadata_async_data_free);
g_task_set_source_tag (task, ostree_repo_write_metadata_async);
g_task_run_in_thread (task, (GTaskThreadFunc)write_metadata_thread);
}
/**
@ -2674,15 +2672,18 @@ ostree_repo_write_metadata_finish (OstreeRepo *self,
guchar **out_csum,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
WriteMetadataAsyncData *data;
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == ostree_repo_write_metadata_async);
g_return_val_if_fail (OSTREE_IS_REPO (self), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
g_return_val_if_fail (g_async_result_is_tagged (result, ostree_repo_write_metadata_async), FALSE);
if (g_simple_async_result_propagate_error (simple, error))
data = g_task_propagate_pointer (G_TASK (result), error);
if (data == NULL)
return FALSE;
data = g_simple_async_result_get_op_res_gpointer (simple);
/* Transfer ownership */
*out_csum = data->result_csum;
data->result_csum = NULL;
@ -2920,7 +2921,6 @@ typedef struct {
GInputStream *object;
guint64 file_object_length;
GCancellable *cancellable;
GSimpleAsyncResult *result;
guchar *result_csum;
} WriteContentAsyncData;
@ -2939,19 +2939,21 @@ write_content_async_data_free (gpointer user_data)
}
static void
write_content_thread (GSimpleAsyncResult *res,
write_content_thread (GTask *task,
GObject *object,
gpointer datap,
GCancellable *cancellable)
{
GError *error = NULL;
WriteContentAsyncData *data;
WriteContentAsyncData *data = datap;
data = g_simple_async_result_get_op_res_gpointer (res);
if (!ostree_repo_write_content (data->repo, data->expected_checksum,
data->object, data->file_object_length,
&data->result_csum,
cancellable, &error))
g_simple_async_result_take_error (res, error);
g_task_return_error (task, error);
else
g_task_return_pointer (task, data, NULL);
}
/**
@ -2976,6 +2978,7 @@ ostree_repo_write_content_async (OstreeRepo *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
WriteContentAsyncData *asyncdata;
asyncdata = g_new0 (WriteContentAsyncData, 1);
@ -2985,14 +2988,10 @@ ostree_repo_write_content_async (OstreeRepo *self,
asyncdata->file_object_length = length;
asyncdata->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
asyncdata->result = g_simple_async_result_new ((GObject*) self,
callback, user_data,
ostree_repo_write_content_async);
g_simple_async_result_set_op_res_gpointer (asyncdata->result, asyncdata,
write_content_async_data_free);
g_simple_async_result_run_in_thread (asyncdata->result, write_content_thread, G_PRIORITY_DEFAULT, cancellable);
g_object_unref (asyncdata->result);
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
g_task_set_task_data (task, asyncdata, (GDestroyNotify)write_content_async_data_free);
g_task_set_source_tag (task, ostree_repo_write_content_async);
g_task_run_in_thread (task, (GTaskThreadFunc)write_content_thread);
}
/**
@ -3010,15 +3009,18 @@ ostree_repo_write_content_finish (OstreeRepo *self,
guchar **out_csum,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
WriteContentAsyncData *data;
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == ostree_repo_write_content_async);
g_return_val_if_fail (OSTREE_IS_REPO (self), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
g_return_val_if_fail (g_async_result_is_tagged (result, ostree_repo_write_content_async), FALSE);
if (g_simple_async_result_propagate_error (simple, error))
data = g_task_propagate_pointer (G_TASK (result), error);
if (data == NULL)
return FALSE;
data = g_simple_async_result_get_op_res_gpointer (simple);
ot_transfer_out_value (out_csum, &data->result_csum);
return TRUE;
}
@ -4336,7 +4338,7 @@ ostree_repo_commit_modifier_unref (OstreeRepoCommitModifier *modifier)
if (modifier->xattr_destroy)
modifier->xattr_destroy (modifier->xattr_user_data);
g_clear_pointer (&modifier->devino_cache, (GDestroyNotify)g_hash_table_unref);
g_clear_pointer (&modifier->devino_cache, g_hash_table_unref);
g_clear_object (&modifier->sepolicy);

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -55,8 +56,8 @@ ostree_repo_file_finalize (GObject *object)
self = OSTREE_REPO_FILE (object);
g_clear_pointer (&self->tree_contents, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&self->tree_metadata, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&self->tree_contents, g_variant_unref);
g_clear_pointer (&self->tree_metadata, g_variant_unref);
g_free (self->cached_file_checksum);
g_free (self->tree_contents_checksum);
g_free (self->tree_metadata_checksum);
@ -236,7 +237,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;
g_clear_pointer (&files_variant, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&files_variant, g_variant_unref);
g_variant_get_child (container, i, "(&s@ay@ay)",
&name, &contents_csum_v, &metadata_csum_v);
@ -337,7 +338,7 @@ ostree_repo_file_tree_set_metadata (OstreeRepoFile *self,
const char *checksum,
GVariant *metadata)
{
g_clear_pointer (&self->tree_metadata, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&self->tree_metadata, g_variant_unref);
self->tree_metadata = g_variant_ref (metadata);
g_free (self->tree_metadata_checksum);
self->tree_metadata_checksum = g_strdup (checksum);
@ -414,8 +415,8 @@ ostree_repo_file_get_checksum (OstreeRepoFile *self)
g_variant_get_child (files_variant, n,
"(@s@ay)", NULL, &csum_bytes);
}
g_clear_pointer (&files_variant, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&dirs_variant, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&files_variant, g_variant_unref);
g_clear_pointer (&dirs_variant, g_variant_unref);
self->cached_file_checksum = ostree_checksum_from_bytes_v (csum_bytes);
@ -775,9 +776,9 @@ ostree_repo_file_tree_find_child (OstreeRepoFile *self,
*out_container = ret_container;
ret_container = NULL;
}
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);
g_clear_pointer (&ret_container, g_variant_unref);
g_clear_pointer (&files_variant, g_variant_unref);
g_clear_pointer (&dirs_variant, g_variant_unref);
return i;
}
@ -969,7 +970,7 @@ ostree_repo_file_read (GFile *file,
return g_file_read (dest, cancellable, error);
}
return g_steal_pointer (&ret_stream);
return (GFileInputStream *)g_steal_pointer (&ret_stream);
}
static void

View File

@ -1,6 +1,7 @@
/*
* Copyright © 2016 Kinvolk GmbH
* Copyright © 2017 Endless Mobile, Inc.
* Copyright © 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -53,7 +54,6 @@
#include "ostree-repo-private.h"
#include "ostree-repo.h"
#include "ostree-repo-finder-avahi-private.h"
#include "ostree-soup-uri.h"
#include "otutil.h"
#endif /* HAVE_AVAHI */
@ -490,7 +490,7 @@ fill_refs_and_checksums_from_summary (GVariant *summary,
return FALSE;
}
g_clear_pointer (&ref_map, (GDestroyNotify) g_variant_iter_free);
g_clear_pointer (&ref_map, g_variant_iter_free);
/* Repeat for the other collections listed in the summary. */
if (g_variant_dict_lookup (&additional_metadata, OSTREE_SUMMARY_COLLECTION_MAP, "a{sa(s(taya{sv}))}", &collection_map))
@ -705,7 +705,7 @@ ostree_avahi_service_build_repo_finder_result (OstreeAvahiService
g_autoptr(GVariant) repo_index = NULL;
g_autofree gchar *repo_path = NULL;
g_autoptr(GPtrArray) possible_refs = NULL; /* (element-type OstreeCollectionRef) */
SoupURI *_uri = NULL;
GUri *_uri = NULL;
g_autofree gchar *uri = NULL;
g_autoptr(GError) error = NULL;
gsize i;
@ -772,13 +772,9 @@ ostree_avahi_service_build_repo_finder_result (OstreeAvahiService
repo_to_refs = g_hash_table_new_full (uri_and_keyring_hash, uri_and_keyring_equal,
(GDestroyNotify) uri_and_keyring_free, (GDestroyNotify) g_hash_table_unref);
_uri = soup_uri_new (NULL);
soup_uri_set_scheme (_uri, "http");
soup_uri_set_host (_uri, service->address);
soup_uri_set_port (_uri, service->port);
soup_uri_set_path (_uri, repo_path);
uri = soup_uri_to_string (_uri, FALSE);
soup_uri_free (_uri);
_uri = g_uri_build (G_URI_FLAGS_ENCODED, "http", NULL, service->address, service->port, repo_path, NULL, NULL);
uri = g_uri_to_string (_uri);
g_uri_unref (_uri);
for (i = 0; i < possible_refs->len; i++)
{

View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2011,2012,2013 Colin Walters <walters@verbum.org>
* Copyright © 2017 Endless Mobile, Inc.
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -435,7 +436,7 @@ idle_worker (gpointer user_data)
scan_data = g_queue_pop_head (&pull_data->scan_object_queue);
if (!scan_data)
{
g_clear_pointer (&pull_data->idle_src, (GDestroyNotify) g_source_destroy);
g_clear_pointer (&pull_data->idle_src, g_source_destroy);
return G_SOURCE_REMOVE;
}
@ -4476,7 +4477,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
pull_data->remote_name);
summary_from_cache = FALSE;
g_clear_pointer (&bytes_summary, (GDestroyNotify)g_bytes_unref);
g_clear_pointer (&bytes_summary, g_bytes_unref);
g_clear_pointer (&summary_etag, g_free);
summary_last_modified = 0;
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
@ -4544,7 +4545,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
pull_data->remote_name);
summary_from_cache = FALSE;
g_clear_pointer (&bytes_summary, (GDestroyNotify)g_bytes_unref);
g_clear_pointer (&bytes_summary, g_bytes_unref);
g_clear_pointer (&summary_etag, g_free);
summary_last_modified = 0;
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
@ -5153,46 +5154,46 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_source_destroy (update_timeout);
g_strfreev (configured_branches);
g_clear_object (&pull_data->fetcher);
g_clear_pointer (&pull_data->extra_headers, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&pull_data->extra_headers, g_variant_unref);
g_clear_object (&pull_data->cancellable);
g_clear_pointer (&pull_data->localcache_repos, (GDestroyNotify)g_ptr_array_unref);
g_clear_pointer (&pull_data->localcache_repos, g_ptr_array_unref);
g_clear_object (&pull_data->remote_repo_local);
g_free (pull_data->remote_refspec_name);
g_free (pull_data->remote_name);
g_free (pull_data->append_user_agent);
g_clear_pointer (&pull_data->signapi_commit_verifiers, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&pull_data->signapi_summary_verifiers, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&pull_data->meta_mirrorlist, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&pull_data->content_mirrorlist, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&pull_data->summary_data, (GDestroyNotify) g_bytes_unref);
g_clear_pointer (&pull_data->signapi_commit_verifiers, g_ptr_array_unref);
g_clear_pointer (&pull_data->signapi_summary_verifiers, g_ptr_array_unref);
g_clear_pointer (&pull_data->meta_mirrorlist, g_ptr_array_unref);
g_clear_pointer (&pull_data->content_mirrorlist, g_ptr_array_unref);
g_clear_pointer (&pull_data->summary_data, g_bytes_unref);
g_clear_pointer (&pull_data->summary_etag, g_free);
g_clear_pointer (&pull_data->summary_data_sig, (GDestroyNotify) g_bytes_unref);
g_clear_pointer (&pull_data->summary_data_sig, g_bytes_unref);
g_clear_pointer (&pull_data->summary_sig_etag, g_free);
g_clear_pointer (&pull_data->summary, (GDestroyNotify) g_variant_unref);
g_clear_pointer (&pull_data->static_delta_superblocks, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&pull_data->commit_to_depth, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->expected_commit_sizes, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->scanned_metadata, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->fetched_detached_metadata, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->summary_deltas_checksums, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->ref_original_commits, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->summary, g_variant_unref);
g_clear_pointer (&pull_data->static_delta_superblocks, g_ptr_array_unref);
g_clear_pointer (&pull_data->commit_to_depth, g_hash_table_unref);
g_clear_pointer (&pull_data->expected_commit_sizes, g_hash_table_unref);
g_clear_pointer (&pull_data->scanned_metadata, g_hash_table_unref);
g_clear_pointer (&pull_data->fetched_detached_metadata, g_hash_table_unref);
g_clear_pointer (&pull_data->summary_deltas_checksums, g_hash_table_unref);
g_clear_pointer (&pull_data->ref_original_commits, g_hash_table_unref);
g_free (pull_data->timestamp_check_from_rev);
g_clear_pointer (&pull_data->verified_commits, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->signapi_verified_commits, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->ref_keyring_map, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->requested_content, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->requested_fallback_content, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->requested_metadata, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_content, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_metadata, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_delta_indexes, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_delta_superblocks, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_deltaparts, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->verified_commits, g_hash_table_unref);
g_clear_pointer (&pull_data->signapi_verified_commits, g_hash_table_unref);
g_clear_pointer (&pull_data->ref_keyring_map, g_hash_table_unref);
g_clear_pointer (&pull_data->requested_content, g_hash_table_unref);
g_clear_pointer (&pull_data->requested_fallback_content, g_hash_table_unref);
g_clear_pointer (&pull_data->requested_metadata, g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_content, g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_metadata, g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_delta_indexes, g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_delta_superblocks, g_hash_table_unref);
g_clear_pointer (&pull_data->pending_fetch_deltaparts, g_hash_table_unref);
g_queue_foreach (&pull_data->scan_object_queue, (GFunc) scan_object_queue_data_free, NULL);
g_queue_clear (&pull_data->scan_object_queue);
g_clear_pointer (&pull_data->idle_src, (GDestroyNotify) g_source_destroy);
g_clear_pointer (&pull_data->dirs, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&remote_config, (GDestroyNotify) g_key_file_unref);
g_clear_pointer (&pull_data->idle_src, g_source_destroy);
g_clear_pointer (&pull_data->dirs, g_ptr_array_unref);
g_clear_pointer (&remote_config, g_key_file_unref);
return ret;
}
@ -5838,7 +5839,7 @@ find_remotes_cb (GObject *obj,
{
g_debug ("%s: Failed to download summary for result %s. Ignoring. %s",
G_STRFUNC, result->remote->name, error->message);
g_clear_pointer (&g_ptr_array_index (results, i), (GDestroyNotify) ostree_repo_finder_result_free);
g_clear_pointer (&g_ptr_array_index (results, i), ostree_repo_finder_result_free);
g_clear_error (&error);
continue;
}
@ -5847,7 +5848,7 @@ find_remotes_cb (GObject *obj,
g_debug ("%s: Failed to download summary for result %s. Ignoring. %s",
G_STRFUNC, result->remote->name,
"No summary file exists on server");
g_clear_pointer (&g_ptr_array_index (results, i), (GDestroyNotify) ostree_repo_finder_result_free);
g_clear_pointer (&g_ptr_array_index (results, i), ostree_repo_finder_result_free);
continue;
}
@ -5869,7 +5870,7 @@ find_remotes_cb (GObject *obj,
if (!find_remotes_process_refs (self, refs, result, i, summary_collection_id, summary_refs,
commit_metadatas, refs_and_remotes_table))
{
g_clear_pointer (&g_ptr_array_index (results, i), (GDestroyNotify) ostree_repo_finder_result_free);
g_clear_pointer (&g_ptr_array_index (results, i), ostree_repo_finder_result_free);
continue;
}
}
@ -5890,7 +5891,7 @@ find_remotes_cb (GObject *obj,
if (!find_remotes_process_refs (self, refs, result, i, summary_collection_id, summary_refs,
commit_metadatas, refs_and_remotes_table))
{
g_clear_pointer (&g_ptr_array_index (results, i), (GDestroyNotify) ostree_repo_finder_result_free);
g_clear_pointer (&g_ptr_array_index (results, i), ostree_repo_finder_result_free);
invalid_result = TRUE;
break;
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2013,2014 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -285,7 +286,6 @@ typedef struct {
GVariant *header;
GVariant *part;
GCancellable *cancellable;
GSimpleAsyncResult *result;
} StaticDeltaPartExecuteAsyncData;
static void
@ -301,20 +301,22 @@ static_delta_part_execute_async_data_free (gpointer user_data)
}
static void
static_delta_part_execute_thread (GSimpleAsyncResult *res,
static_delta_part_execute_thread (GTask *task,
GObject *object,
gpointer datap,
GCancellable *cancellable)
{
GError *error = NULL;
StaticDeltaPartExecuteAsyncData *data;
StaticDeltaPartExecuteAsyncData *data = datap;
data = g_simple_async_result_get_op_res_gpointer (res);
if (!_ostree_static_delta_part_execute (data->repo,
data->header,
data->part,
FALSE, NULL,
cancellable, &error))
g_simple_async_result_take_error (res, error);
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
}
void
@ -325,6 +327,7 @@ _ostree_static_delta_part_execute_async (OstreeRepo *repo,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
StaticDeltaPartExecuteAsyncData *asyncdata;
asyncdata = g_new0 (StaticDeltaPartExecuteAsyncData, 1);
@ -333,14 +336,10 @@ _ostree_static_delta_part_execute_async (OstreeRepo *repo,
asyncdata->part = g_variant_ref (part);
asyncdata->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
asyncdata->result = g_simple_async_result_new ((GObject*) repo,
callback, user_data,
_ostree_static_delta_part_execute_async);
g_simple_async_result_set_op_res_gpointer (asyncdata->result, asyncdata,
static_delta_part_execute_async_data_free);
g_simple_async_result_run_in_thread (asyncdata->result, static_delta_part_execute_thread, G_PRIORITY_DEFAULT, cancellable);
g_object_unref (asyncdata->result);
task = g_task_new (G_OBJECT (repo), cancellable, callback, user_data);
g_task_set_task_data (task, asyncdata, (GDestroyNotify)static_delta_part_execute_async_data_free);
g_task_set_source_tag (task, _ostree_static_delta_part_execute_async);
g_task_run_in_thread (task, (GTaskThreadFunc)static_delta_part_execute_thread);
}
gboolean
@ -348,13 +347,13 @@ _ostree_static_delta_part_execute_finish (OstreeRepo *repo,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
g_return_val_if_fail (OSTREE_IS_REPO (repo), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, repo), FALSE);
g_return_val_if_fail (g_async_result_is_tagged (result, _ostree_static_delta_part_execute_async), FALSE);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == _ostree_static_delta_part_execute_async);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
return TRUE;
return g_task_propagate_boolean (G_TASK (result), error);
}
static gboolean

View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -1208,8 +1209,8 @@ ostree_repo_finalize (GObject *object)
g_clear_pointer (&self->txn.refs, g_hash_table_destroy);
g_clear_pointer (&self->txn.collection_refs, g_hash_table_destroy);
g_clear_error (&self->writable_error);
g_clear_pointer (&self->object_sizes, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&self->dirmeta_cache, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&self->object_sizes, g_hash_table_unref);
g_clear_pointer (&self->dirmeta_cache, g_hash_table_unref);
g_mutex_clear (&self->cache_lock);
g_mutex_clear (&self->txn_lock);
g_free (self->collection_id);
@ -2306,7 +2307,7 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
goto out;
}
g_clear_pointer (&data_buffer, (GDestroyNotify) gpgme_data_release);
g_clear_pointer (&data_buffer, gpgme_data_release);
}
/* Retrieve all keys or specific keys from the source GPGME context.
@ -3179,7 +3180,7 @@ reload_core_config (OstreeRepo *self,
gboolean is_archive;
gsize len;
g_clear_pointer (&self->config, (GDestroyNotify)g_key_file_unref);
g_clear_pointer (&self->config, g_key_file_unref);
self->config = g_key_file_new ();
contents = glnx_file_get_contents_utf8_at (self->repo_dir_fd, "config", &len,
@ -6274,7 +6275,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
g_autoptr(GHashTable) collection_map = NULL; /* (element-type utf8 GHashTable) */
g_hash_table_iter_init (&iter, collection_refs);
collection_map = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
(GDestroyNotify) g_hash_table_unref);
(GDestroyNotify)g_hash_table_unref);
const OstreeCollectionRef *c_ref;
const char *checksum;
@ -6594,7 +6595,7 @@ _ostree_repo_memory_cache_ref_destroy (OstreeRepoMemoryCacheRef *state)
g_mutex_lock (lock);
repo->dirmeta_cache_refcount--;
if (repo->dirmeta_cache_refcount == 0)
g_clear_pointer (&repo->dirmeta_cache, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&repo->dirmeta_cache, g_hash_table_unref);
g_mutex_unlock (lock);
g_object_unref (repo);
}

View File

@ -1,140 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* soup-form.c : utility functions for HTML forms */
/*
* Copyright 2008 Red Hat, Inc.
*/
/* This one is stripped down to only have soup_form_encode_hash()
* and soup_form_encode_valist() which are the only bits that soup-uri.c
* calls.
*/
#include <config.h>
#include <string.h>
#include "ostree-soup-uri.h"
/**
* SECTION:soup-form
* @short_description: HTML form handling
* @see_also: #SoupMultipart
*
* libsoup contains several help methods for processing HTML forms as
* defined by <ulink
* url="http://www.w3.org/TR/html401/interact/forms.html#h-17.13">the
* HTML 4.01 specification</ulink>.
**/
/**
* SOUP_FORM_MIME_TYPE_URLENCODED:
*
* A macro containing the value
* <literal>"application/x-www-form-urlencoded"</literal>; the default
* MIME type for POSTing HTML form data.
*
* Since: 2.26
**/
/**
* SOUP_FORM_MIME_TYPE_MULTIPART:
*
* A macro containing the value
* <literal>"multipart/form-data"</literal>; the MIME type used for
* posting form data that contains files to be uploaded.
*
* Since: 2.26
**/
#define XDIGIT(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
#define HEXCHAR(s) ((XDIGIT (s[1]) << 4) + XDIGIT (s[2]))
static void
append_form_encoded (GString *str, const char *in)
{
const unsigned char *s = (const unsigned char *)in;
while (*s) {
if (*s == ' ') {
g_string_append_c (str, '+');
s++;
} else if (!g_ascii_isalnum (*s) && (*s != '-') && (*s != '_')
&& (*s != '.'))
g_string_append_printf (str, "%%%02X", (int)*s++);
else
g_string_append_c (str, *s++);
}
}
static void
encode_pair (GString *str, const char *name, const char *value)
{
g_return_if_fail (name != NULL);
g_return_if_fail (value != NULL);
if (str->len)
g_string_append_c (str, '&');
append_form_encoded (str, name);
g_string_append_c (str, '=');
append_form_encoded (str, value);
}
/**
* soup_form_encode_hash:
* @form_data_set: (element-type utf8 utf8) (transfer none): a hash table containing
* name/value pairs (as strings)
*
* Encodes @form_data_set into a value of type
* "application/x-www-form-urlencoded", as defined in the HTML 4.01
* spec.
*
* Note that the HTML spec states that "The control names/values are
* listed in the order they appear in the document." Since this method
* takes a hash table, it cannot enforce that; if you care about the
* ordering of the form fields, use soup_form_encode_datalist().
*
* Return value: the encoded form
**/
char *
soup_form_encode_hash (GHashTable *form_data_set)
{
GString *str = g_string_new (NULL);
GHashTableIter iter;
gpointer name, value;
g_hash_table_iter_init (&iter, form_data_set);
while (g_hash_table_iter_next (&iter, &name, &value))
encode_pair (str, name, value);
return g_string_free (str, FALSE);
}
/**
* soup_form_encode_valist:
* @first_field: name of the first form field
* @args: pointer to additional values, as in soup_form_encode()
*
* See soup_form_encode(). This is mostly an internal method, used by
* various other methods such as soup_uri_set_query_from_fields() and
* soup_form_request_new().
*
* Return value: the encoded form
**/
char *
soup_form_encode_valist (const char *first_field, va_list args)
{
GString *str = g_string_new (NULL);
const char *name, *value;
name = first_field;
value = va_arg (args, const char *);
while (name && value) {
encode_pair (str, name, value);
name = va_arg (args, const char *);
if (name)
value = va_arg (args, const char *);
}
return g_string_free (str, FALSE);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,147 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright 1999-2002 Ximian, Inc.
*/
/* NOTE - taken from the libsoup codebase for use by the ostree curl backend
* (yes, ironically enough).
*
* Please watch for future changes in libsoup.
*/
#ifndef SOUP_URI_H
#define SOUP_URI_H 1
/* OSTREECHANGE: make struct private
* Only include gio, and skip available definitions.
*/
#include <gio/gio.h>
#define SOUP_AVAILABLE_IN_2_4
#define SOUP_AVAILABLE_IN_2_28
#define SOUP_AVAILABLE_IN_2_32
G_BEGIN_DECLS
/* OSTREECHANGE: make struct private */
typedef struct _SoupURI SoupURI;
/* OSTREECHANGE: import soup-misc's interning */
#define SOUP_VAR extern
#define _SOUP_ATOMIC_INTERN_STRING(variable, value) ((const char *)(g_atomic_pointer_get (&(variable)) ? (variable) : (g_atomic_pointer_set (&(variable), (gpointer)g_intern_static_string (value)), (variable))))
#define SOUP_URI_SCHEME_HTTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http")
#define SOUP_URI_SCHEME_HTTPS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "https")
#define SOUP_URI_SCHEME_FTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FTP, "ftp")
#define SOUP_URI_SCHEME_FILE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FILE, "file")
#define SOUP_URI_SCHEME_DATA _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_DATA, "data")
#define SOUP_URI_SCHEME_RESOURCE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_RESOURCE, "resource")
#define SOUP_URI_SCHEME_WS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WS, "ws")
#define SOUP_URI_SCHEME_WSS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WSS, "wss")
/* OSTREECHANGE: import soup-form bits */
SOUP_AVAILABLE_IN_2_4
char *soup_form_encode_hash (GHashTable *form_data_set);
SOUP_AVAILABLE_IN_2_4
char *soup_form_encode_valist (const char *first_field,
va_list args);
SOUP_VAR gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
SOUP_VAR gpointer _SOUP_URI_SCHEME_FTP;
SOUP_VAR gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA, _SOUP_URI_SCHEME_RESOURCE;
SOUP_VAR gpointer _SOUP_URI_SCHEME_WS, _SOUP_URI_SCHEME_WSS;
SOUP_AVAILABLE_IN_2_4
SoupURI *soup_uri_new_with_base (SoupURI *base,
const char *uri_string);
SOUP_AVAILABLE_IN_2_4
SoupURI *soup_uri_new (const char *uri_string);
SOUP_AVAILABLE_IN_2_4
char *soup_uri_to_string (SoupURI *uri,
gboolean just_path_and_query);
SOUP_AVAILABLE_IN_2_4
SoupURI *soup_uri_copy (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
gboolean soup_uri_equal (SoupURI *uri1,
SoupURI *uri2);
SOUP_AVAILABLE_IN_2_4
void soup_uri_free (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
char *soup_uri_encode (const char *part,
const char *escape_extra);
SOUP_AVAILABLE_IN_2_4
char *soup_uri_decode (const char *part);
SOUP_AVAILABLE_IN_2_4
char *soup_uri_normalize (const char *part,
const char *unescape_extra);
SOUP_AVAILABLE_IN_2_4
gboolean soup_uri_uses_default_port (SoupURI *uri);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_scheme (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_scheme (SoupURI *uri,
const char *scheme);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_user (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_user (SoupURI *uri,
const char *user);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_password (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_password (SoupURI *uri,
const char *password);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_host (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_host (SoupURI *uri,
const char *host);
SOUP_AVAILABLE_IN_2_32
guint soup_uri_get_port (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_port (SoupURI *uri,
guint port);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_path (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_path (SoupURI *uri,
const char *path);
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_query (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_query (SoupURI *uri,
const char *query);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_query_from_form (SoupURI *uri,
GHashTable *form);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_query_from_fields (SoupURI *uri,
const char *first_field,
...) G_GNUC_NULL_TERMINATED;
SOUP_AVAILABLE_IN_2_32
const char *soup_uri_get_fragment (SoupURI *uri);
SOUP_AVAILABLE_IN_2_4
void soup_uri_set_fragment (SoupURI *uri,
const char *fragment);
SOUP_AVAILABLE_IN_2_28
SoupURI *soup_uri_copy_host (SoupURI *uri);
SOUP_AVAILABLE_IN_2_28
guint soup_uri_host_hash (gconstpointer key);
SOUP_AVAILABLE_IN_2_28
gboolean soup_uri_host_equal (gconstpointer v1,
gconstpointer v2);
#define SOUP_URI_IS_VALID(uri) ((uri) && (uri)->scheme && (uri)->path)
#define SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
G_END_DECLS
#endif /*SOUP_URI_H*/

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -82,7 +83,7 @@ ostree_sysroot_finalize (GObject *object)
g_clear_pointer (&self->deployments, g_ptr_array_unref);
g_clear_object (&self->booted_deployment);
g_clear_object (&self->staged_deployment);
g_clear_pointer (&self->staged_deployment_data, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&self->staged_deployment_data, g_variant_unref);
glnx_release_lock_file (&self->lock);
@ -1016,7 +1017,7 @@ _ostree_sysroot_reload_staged (OstreeSysroot *self,
g_assert (self->booted_deployment);
g_clear_object (&self->staged_deployment);
g_clear_pointer (&self->staged_deployment_data, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&self->staged_deployment_data, g_variant_unref);
/* Read the staged state from disk */
glnx_autofd int fd = -1;

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -22,12 +23,12 @@
#include "ot-checksum-instream.h"
#include "ot-checksum-utils.h"
G_DEFINE_TYPE (OtChecksumInstream, ot_checksum_instream, G_TYPE_FILTER_INPUT_STREAM)
struct _OtChecksumInstreamPrivate {
OtChecksum checksum;
};
G_DEFINE_TYPE_WITH_PRIVATE (OtChecksumInstream, ot_checksum_instream, G_TYPE_FILTER_INPUT_STREAM)
static gssize ot_checksum_instream_read (GInputStream *stream,
void *buffer,
gsize count,
@ -50,8 +51,6 @@ ot_checksum_instream_class_init (OtChecksumInstreamClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
g_type_class_add_private (klass, sizeof (OtChecksumInstreamPrivate));
object_class->finalize = ot_checksum_instream_finalize;
stream_class->read_fn = ot_checksum_instream_read;
}
@ -59,7 +58,7 @@ ot_checksum_instream_class_init (OtChecksumInstreamClass *klass)
static void
ot_checksum_instream_init (OtChecksumInstream *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OT_TYPE_CHECKSUM_INSTREAM, OtChecksumInstreamPrivate);
self->priv = ot_checksum_instream_get_instance_private (self);
}
OtChecksumInstream *

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -129,7 +130,7 @@ ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,
goto out;
/* Sneaky cast from GFileOutputStream to GOutputStream. */
*out_pubring_stream = g_steal_pointer (&pubring_stream);
*out_pubring_stream = (GOutputStream *)g_steal_pointer (&pubring_stream);
}
if (out_tmp_home_dir != NULL)

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -419,7 +420,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
}
}
g_clear_pointer (&objects, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&objects, g_hash_table_unref);
if (!opt_quiet)
g_print ("Verifying content integrity of %u commit objects...\n",

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -133,7 +134,7 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
g_free (next_checksum);
next_checksum = ostree_commit_get_parent (commit);
if (next_checksum)
g_clear_pointer (&commit, (GDestroyNotify)g_variant_unref);
g_clear_pointer (&commit, g_variant_unref);
else
break; /* No parent, we're done */
}

View File

@ -1,5 +1,6 @@
/*
* Copyright © 2017 Endless Mobile, Inc.
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -47,7 +48,7 @@ result_cb (GObject *source_object,
static void
collection_ref_free0 (OstreeCollectionRef *ref)
{
g_clear_pointer (&ref, (GDestroyNotify) ostree_collection_ref_free);
g_clear_pointer (&ref, ostree_collection_ref_free);
}
int

View File

@ -1,5 +1,6 @@
/*
* Copyright © 2017 Endless Mobile, Inc.
* Copyright (C) 2022 Igalia S.L.
*
* SPDX-License-Identifier: LGPL-2.0+
*
@ -136,7 +137,7 @@ ostree_mock_volume_monitor_new (GList *mounts,
monitor->mounts = g_list_copy_deep (mounts, (GCopyFunc) g_object_ref, NULL);
monitor->volumes = g_list_copy_deep (volumes, (GCopyFunc) g_object_ref, NULL);
return g_steal_pointer (&monitor);
return (GVolumeMonitor *)g_steal_pointer (&monitor);
}
/* Mock volume class. This returns a static set of data to the caller, which it