lib/gpg: Switch to GLib autocleanups for gpgme types

Prep for dropping `GLNX_DEFINE_CLEANUP_FUNCTION` from libglnx
in favor of using GLib's `G_DEFINE_AUTO_CLEANUP_FREE_FUNC()`.

Closes: #1042
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-07-31 13:24:25 -04:00 committed by Atomic Bot
parent 6347c0fb88
commit ded6417aee
4 changed files with 9 additions and 11 deletions

View File

@ -95,8 +95,8 @@ _ostree_gpg_verifier_check_signature (OstreeGpgVerifier *self,
{ {
GLNX_AUTO_PREFIX_ERROR("GPG", error); GLNX_AUTO_PREFIX_ERROR("GPG", error);
gpgme_error_t gpg_error = 0; gpgme_error_t gpg_error = 0;
ot_auto_gpgme_data gpgme_data_t data_buffer = NULL; g_auto(gpgme_data_t) data_buffer = NULL;
ot_auto_gpgme_data gpgme_data_t signature_buffer = NULL; g_auto(gpgme_data_t) signature_buffer = NULL;
g_autofree char *tmp_dir = NULL; g_autofree char *tmp_dir = NULL;
g_autoptr(GOutputStream) target_stream = NULL; g_autoptr(GOutputStream) target_stream = NULL;
OstreeGpgVerifyResult *result = NULL; OstreeGpgVerifyResult *result = NULL;
@ -165,7 +165,7 @@ _ostree_gpg_verifier_check_signature (OstreeGpgVerifier *self,
{ {
const char *path = self->key_ascii_files->pdata[i]; const char *path = self->key_ascii_files->pdata[i];
glnx_fd_close int fd = -1; glnx_fd_close int fd = -1;
ot_auto_gpgme_data gpgme_data_t kdata = NULL; g_auto(gpgme_data_t) kdata = NULL;
if (!glnx_openat_rdonly (AT_FDCWD, path, TRUE, &fd, error)) if (!glnx_openat_rdonly (AT_FDCWD, path, TRUE, &fd, error))
goto out; goto out;

View File

@ -1331,9 +1331,9 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
GError **error) GError **error)
{ {
OstreeRemote *remote; OstreeRemote *remote;
ot_auto_gpgme_ctx gpgme_ctx_t source_context = NULL; g_auto(gpgme_ctx_t) source_context = NULL;
ot_auto_gpgme_ctx gpgme_ctx_t target_context = NULL; g_auto(gpgme_ctx_t) target_context = NULL;
ot_auto_gpgme_data gpgme_data_t data_buffer = NULL; g_auto(gpgme_data_t) data_buffer = NULL;
gpgme_import_result_t import_result; gpgme_import_result_t import_result;
gpgme_import_status_t import_status; gpgme_import_status_t import_status;
g_autofree char *source_tmp_dir = NULL; g_autofree char *source_tmp_dir = NULL;

View File

@ -413,7 +413,7 @@ ot_gpgme_new_ctx (const char *homedir,
GError **error) GError **error)
{ {
gpgme_error_t err; gpgme_error_t err;
ot_auto_gpgme_ctx gpgme_ctx_t context = NULL; g_auto(gpgme_ctx_t) context = NULL;
if ((err = gpgme_new (&context)) != GPG_ERR_NO_ERROR) if ((err = gpgme_new (&context)) != GPG_ERR_NO_ERROR)
{ {

View File

@ -26,10 +26,8 @@
G_BEGIN_DECLS G_BEGIN_DECLS
GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_data_t, ot_cleanup_gpgme_data, gpgme_data_release) G_DEFINE_AUTO_CLEANUP_FREE_FUNC(gpgme_data_t, gpgme_data_release, NULL);
#define ot_auto_gpgme_data __attribute__((cleanup(ot_cleanup_gpgme_data))) G_DEFINE_AUTO_CLEANUP_FREE_FUNC(gpgme_ctx_t, gpgme_release, NULL);
GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_ctx_t, ot_cleanup_gpgme_ctx, gpgme_release)
#define ot_auto_gpgme_ctx __attribute__((cleanup(ot_cleanup_gpgme_ctx)))
void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error); void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error);