Merge branch 'scan-build-warnings' into 'main'

Add several assertions to help static analysis and fix some GIR annotations

See merge request GNOME/glib!4449
This commit is contained in:
Michael Catanzaro 2025-01-03 21:26:29 +00:00
commit 127d38b0d3
6 changed files with 14 additions and 4 deletions

View File

@ -89,7 +89,7 @@ g_filter_output_stream_class_init (GFilterOutputStreamClass *klass)
ostream_class->close_fn = g_filter_output_stream_close;
/**
* GFilterOutputStream:close-base-stream:
* GFilterOutputStream:base-stream:
*
* The underlying base stream on which the I/O ops will be done.
*/

View File

@ -2991,6 +2991,7 @@ g_get_current_dir (void)
{
/* Fallback return value */
g_assert (buffer_size >= 2);
g_assert (buffer != NULL);
buffer[0] = G_DIR_SEPARATOR;
buffer[1] = 0;
}

View File

@ -2559,7 +2559,7 @@ g_option_context_get_description (GOptionContext *context)
/**
* g_option_context_parse_strv:
* @context: a #GOptionContext
* @arguments: (inout) (array null-terminated=1) (optional): a pointer
* @arguments: (inout) (array zero-terminated=1) (optional): a pointer
* to the command line arguments (which must be in UTF-8 on Windows).
* Starting with GLib 2.62, @arguments can be %NULL, which matches
* g_option_context_parse().

View File

@ -611,7 +611,7 @@
/**
* g_assert_no_error:
* @err: (nullable) a `GError`
* @err: (nullable): a `GError`
*
* Debugging macro to check that a [struct@GLib.Error] is not set.
*

View File

@ -258,6 +258,8 @@ typedef struct
static void
test_error_private_init (TestErrorPrivate *priv)
{
g_assert_nonnull (priv);
priv->foo = 13;
/* If that triggers, it's test bug.
*/
@ -272,15 +274,20 @@ static void
test_error_private_copy (const TestErrorPrivate *src_priv,
TestErrorPrivate *dest_priv)
{
g_assert_nonnull (src_priv);
g_assert_nonnull (dest_priv);
dest_priv->foo = src_priv->foo;
dest_priv->check = src_priv->check;
g_assert_nonnull (dest_priv->check);
dest_priv->check->copy_called++;
}
static void
test_error_private_clear (TestErrorPrivate *priv)
{
g_assert_nonnull (priv->check);
priv->check->free_called++;
}
@ -291,6 +298,7 @@ fill_test_error (GError *error, TestErrorCheck *check)
{
TestErrorPrivate *test_error = test_error_get_private (error);
g_assert_nonnull (test_error);
test_error->check = check;
return test_error;
@ -326,6 +334,7 @@ test_extended (void)
g_assert_cmpstr (error->message, ==, copy_error->message);
copy_test_priv = test_error_get_private (copy_error);
g_assert_nonnull (copy_test_priv);
g_assert_cmpint (test_priv->foo, ==, copy_test_priv->foo);
g_error_free (error);

View File

@ -246,7 +246,7 @@ static void
test_mutex_perf (gconstpointer data)
{
const guint n_threads = GPOINTER_TO_UINT (data);
GThread *threads[THREADS];
GThread *threads[THREADS] = { NULL, };
gint64 start_time;
gdouble rate;
gint x = -1;