keyfile-utils: Quiet a clang-analyzer warning
authorColin Walters <walters@verbum.org>
Wed, 30 Aug 2023 13:19:42 +0000 (09:19 -0400)
committerColin Walters <walters@verbum.org>
Wed, 30 Aug 2023 13:19:42 +0000 (09:19 -0400)
It complains that we could leak memory if the return value
pointer isn't set.  That's actually a nonsensical case, there's
no reason to call this and ignore the return value.

So change things to require it be set, and also change the
`g_return_val_if_fail` to be hard assertions per our new policy.

src/libotutil/ot-keyfile-utils.c

index a1250dc64fde044c4aa3d3759d0d803ccd113f49..d6cd102ca054699196c42b7f0ad655d65f8c0048 100644 (file)
@@ -174,10 +174,11 @@ ot_keyfile_get_string_list_with_separator_choice (GKeyFile *keyfile, const char
                                                   const char *key, const char *separators,
                                                   char ***out_value, GError **error)
 {
-  g_return_val_if_fail (keyfile != NULL, FALSE);
-  g_return_val_if_fail (section != NULL, FALSE);
-  g_return_val_if_fail (key != NULL, FALSE);
-  g_return_val_if_fail (separators != NULL, FALSE);
+  g_assert (keyfile != NULL);
+  g_assert (section != NULL);
+  g_assert (key != NULL);
+  g_assert (separators != NULL);
+  g_assert (out_value != NULL);
 
   g_autofree char *value_str = NULL;
   if (!ot_keyfile_get_value_with_default (keyfile, section, key, NULL, &value_str, error))
@@ -215,7 +216,7 @@ ot_keyfile_get_string_list_with_separator_choice (GKeyFile *keyfile, const char
         }
     }
 
-  ot_transfer_out_value (out_value, &value_list);
+  *out_value = g_steal_pointer (&value_list);
   return TRUE;
 }