diff --git a/gio/tests/socket-client.c b/gio/tests/socket-client.c index 92bf41fb9..025632767 100644 --- a/gio/tests/socket-client.c +++ b/gio/tests/socket-client.c @@ -249,14 +249,14 @@ int main (int argc, char *argv[]) { - GSocket *socket; - GSocketAddress *address; + GSocket *socket = NULL; + GSocketAddress *address = NULL; GError *error = NULL; GOptionContext *context; GCancellable *cancellable; - GIOStream *connection; - GInputStream *istream; - GOutputStream *ostream; + GIOStream *connection = NULL; + GInputStream *istream = NULL; + GOutputStream *ostream = NULL; GSocketAddress *src_address = NULL; GTlsCertificate *certificate = NULL; gint i; diff --git a/glib/garray.c b/glib/garray.c index 920a40258..f77ef1990 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -1555,9 +1555,14 @@ g_ptr_array_free (GPtrArray *array, /* if others are holding a reference, preserve the wrapper but * do free/return the data + * + * Coverity doesn’t understand this and assumes it’s a leak, so comment this + * out. */ +#ifndef __COVERITY__ if (!g_atomic_ref_count_dec (&rarray->ref_count)) flags |= PRESERVE_WRAPPER; +#endif return ptr_array_free (array, flags); } diff --git a/glib/gvariant.c b/glib/gvariant.c index e9399710e..062c2582e 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -3484,8 +3484,19 @@ g_variant_builder_init (GVariantBuilder *builder, g_assert_not_reached (); } +#ifdef G_ANALYZER_ANALYZING + /* Static analysers can’t couple the code in g_variant_builder_init() to the + * code in g_variant_builder_end() by GVariantType, so end up assuming that + * @offset and @children mismatch and that uninitialised memory is accessed + * from @children. At runtime, this is caught by the preconditions at the top + * of g_variant_builder_end(). Help the analyser by zero-initialising the + * memory to avoid a false positive. */ + GVSB(builder)->children = g_new0 (GVariant *, + GVSB(builder)->allocated_children); +#else GVSB(builder)->children = g_new (GVariant *, GVSB(builder)->allocated_children); +#endif } static void diff --git a/glib/tests/mutex.c b/glib/tests/mutex.c index a5ba2ea95..120229e42 100644 --- a/glib/tests/mutex.c +++ b/glib/tests/mutex.c @@ -186,7 +186,7 @@ addition_thread (gpointer value) static void test_mutex_perf (gconstpointer data) { - guint n_threads = GPOINTER_TO_UINT (data); + const guint n_threads = GPOINTER_TO_UINT (data); GThread *threads[THREADS]; gint64 start_time; gdouble rate; diff --git a/glib/tests/slice-memchunk.c b/glib/tests/slice-memchunk.c index 0938eb96f..ea8bee0c0 100644 --- a/glib/tests/slice-memchunk.c +++ b/glib/tests/slice-memchunk.c @@ -25,11 +25,11 @@ #define quick_rand32() \ (rand_accu = 1664525 * rand_accu + 1013904223, rand_accu) -static guint prime_size = 1021; /* 769; 509 */ -static gboolean clean_memchunks = FALSE; -static guint number_of_blocks = 10000; /* total number of blocks allocated */ -static guint number_of_repetitions = 10000; /* number of alloc+free repetitions */ -static gboolean want_corruption = FALSE; +static const guint prime_size = 1021; /* 769; 509 */ +static const gboolean clean_memchunks = FALSE; +static const guint number_of_blocks = 10000; /* total number of blocks allocated */ +static const guint number_of_repetitions = 10000; /* number of alloc+free repetitions */ +static const gboolean want_corruption = FALSE; /* --- old memchunk prototypes (memchunks.c) --- */ GMemChunk* old_mem_chunk_new (const gchar *name,