From cd2a555675222aeff8cd23254aae305c6023c83c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 15 Aug 2017 12:28:28 +0100 Subject: [PATCH] common/dir: Clarify the nullability of some variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit flatpak_decompose_ref() can fail, but in this situation we know it won’t since find_matching_refs() checks it for us and hence guarantees that it only returns decomposable refs. Add some assertions to make this clearer and to shut Coverity up. Signed-off-by: Philip Withnall --- common/flatpak-dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 8701971a4..689c3309a 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -6833,6 +6833,7 @@ flatpak_dir_remote_list_refs (FlatpakDir *self, return TRUE; } +/* Guarantees to return refs which are decomposable. */ static GPtrArray * find_matching_refs (GHashTable *refs, const char *opt_name, @@ -6945,6 +6946,7 @@ find_matching_ref (GHashTable *refs, { char *current_ref = g_ptr_array_index (matched_refs, j); g_auto(GStrv) parts = flatpak_decompose_ref (current_ref, NULL); + g_assert (parts != NULL); if (g_strcmp0 (opt_default_branch, parts[3]) == 0) return g_strdup (current_ref); @@ -6958,6 +6960,7 @@ find_matching_ref (GHashTable *refs, for (j = 0; j < matched_refs->len; j++) { g_auto(GStrv) parts = flatpak_decompose_ref (g_ptr_array_index (matched_refs, j), NULL); + g_assert (parts != NULL); if (j != 0) g_string_append (err, ", ");