common/dir: Clarify the nullability of some variables

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 <withnall@endlessm.com>
This commit is contained in:
Philip Withnall committed 2017-08-15 12:28:28 +01:00
1 parent c157719616
commit cd2a555675
1 file changed
+3
+3
View File
@@ -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, ", ");