From f725d39f111bd0d362a583c3a4902e3194fd74d8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 1 Jun 2016 09:35:47 -0400 Subject: [PATCH] lib: Change ot_util_variant_map helpers to consistently sink refs This is similar to changes Krzesimir has been doing recently - we really don't need the ergonomics of floating refs since we have autocleanups. We should continue to change most of our code to sink refs. Specifically here it was pretty broken that the `_map()` API was sinking but the other two weren't, and this broke some refactoring I was trying to do later. Closes: #317 Approved by: jlebon --- src/libostree/ostree-repo-static-delta-core.c | 1 + src/libotutil/ot-variant-utils.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index 9e3ed09f..01383712 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -512,6 +512,7 @@ _ostree_static_delta_part_open (GInputStream *part_in, g_bytes_get_size (inline_part_bytes) - 1); ret_part = g_variant_new_from_bytes (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0), content_bytes, trusted); + g_variant_ref_sink (ret_part); } if (!skip_checksum) diff --git a/src/libotutil/ot-variant-utils.c b/src/libotutil/ot-variant-utils.c index 7b54542e..b9fe94b9 100644 --- a/src/libotutil/ot-variant-utils.c +++ b/src/libotutil/ot-variant-utils.c @@ -166,7 +166,6 @@ ot_util_variant_map_at (int dfd, GError **error) { glnx_fd_close int fd = -1; - g_autoptr(GVariant) ret_variant = NULL; fd = openat (dfd, path, O_RDONLY | O_CLOEXEC); if (fd < 0) @@ -224,8 +223,8 @@ ot_util_variant_map_fd (int fd, mdata->len = len; ret = TRUE; - *out_variant = g_variant_new_from_data (type, map, len, trusted, - variant_map_data_destroy, mdata); + *out_variant = g_variant_ref_sink (g_variant_new_from_data (type, map, len, trusted, + variant_map_data_destroy, mdata)); out: return ret; }