summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-sign.c
diff options
context:
space:
mode:
authorDenis Pynkin <denis.pynkin@collabora.com>2019-09-05 02:04:25 +0300
committerDenis Pynkin <denis.pynkin@collabora.com>2020-03-25 15:23:54 +0300
commit557f42360945b4f70196d7ec4c50443e10918573 (patch)
tree7830926fa4ca32b621b508f6c96da45d046fa966 /src/libostree/ostree-sign.c
parent5fc2ddff30c5c8b40e60fd4dd7a6b8c1fab2e98e (diff)
downloadostree-557f42360945b4f70196d7ec4c50443e10918573.tar.gz
sign: fix memory leaks and code cleanup
Return `const char *` instead of copy of the string -- this allow to avoid unneeded copying and memory leaks in some constructions. Minor code cleanup and optimisations. Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Diffstat (limited to 'src/libostree/ostree-sign.c')
-rw-r--r--src/libostree/ostree-sign.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libostree/ostree-sign.c b/src/libostree/ostree-sign.c
index 5f7078f1..6e67acaa 100644
--- a/src/libostree/ostree-sign.c
+++ b/src/libostree/ostree-sign.c
@@ -71,7 +71,7 @@ ostree_sign_default_init (OstreeSignInterface *iface)
g_debug ("OstreeSign initialization");
}
-gchar * ostree_sign_metadata_key (OstreeSign *self)
+const gchar * ostree_sign_metadata_key (OstreeSign *self)
{
g_debug ("%s enter", __FUNCTION__);
@@ -79,7 +79,7 @@ gchar * ostree_sign_metadata_key (OstreeSign *self)
return OSTREE_SIGN_GET_IFACE (self)->metadata_key (self);
}
-gchar * ostree_sign_metadata_format (OstreeSign *self)
+const gchar * ostree_sign_metadata_format (OstreeSign *self)
{
g_debug ("%s enter", __FUNCTION__);
@@ -134,7 +134,7 @@ ostree_sign_load_pk (OstreeSign *self,
g_debug ("%s enter", __FUNCTION__);
if (OSTREE_SIGN_GET_IFACE (self)->load_pk == NULL)
- return FALSE;
+ return TRUE;
return OSTREE_SIGN_GET_IFACE (self)->load_pk (self, options, error);
}
@@ -170,8 +170,8 @@ ostree_sign_detached_metadata_append (OstreeSign *self,
g_variant_dict_init (&metadata_dict, existing_metadata);
- g_autofree gchar *signature_key = ostree_sign_metadata_key(self);
- g_autofree GVariantType *signature_format = (GVariantType *) ostree_sign_metadata_format(self);
+ const gchar *signature_key = ostree_sign_metadata_key(self);
+ GVariantType *signature_format = (GVariantType *) ostree_sign_metadata_format(self);
signature_data = g_variant_dict_lookup_value (&metadata_dict,
signature_key,
@@ -234,8 +234,8 @@ ostree_sign_commit_verify (OstreeSign *self,
g_autoptr(GVariant) signatures = NULL;
- g_autofree gchar *signature_key = ostree_sign_metadata_key(self);
- g_autofree GVariantType *signature_format = (GVariantType *) ostree_sign_metadata_format(self);
+ const gchar *signature_key = ostree_sign_metadata_key(self);
+ GVariantType *signature_format = (GVariantType *) ostree_sign_metadata_format(self);
if (metadata)
signatures = g_variant_lookup_value (metadata,