From 592082ef1d0400f9615a030f45c51b412189d6c2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Sep 2025 20:02:17 +0200 Subject: [PATCH] gdbus-codegen: Supress coverity warning in skeleton finalization This commit has the potential to close a thousand Coverity issues. On generated code from gdbus-codegen, Coverity typically warns on skeleton->priv->changed_properties_idle_source happening outside the skeleketon->priv->lock during finalize(), while it's protected by this mutex in other parts. Presumably if the object is in finalization, there should be no other threads poking at it, so the code is actually safe for the intended use and the warning moot. To address this, change gdbus-codegen to prefer g_clear_pointer() with glib >= 2.38 (should be most often the case nowadays) so this access is reserved to a single line of code, and mark this line of code with a Coverity code annotation in order to suppress the warning. --- gio/gdbus-2.0/codegen/codegen.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py index 01c53674f..ffdf14a36 100644 --- a/gio/gdbus-2.0/codegen/codegen.py +++ b/gio/gdbus-2.0/codegen/codegen.py @@ -4128,12 +4128,23 @@ class CodeGenerator: self.outfile.write( " g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);\n" ) + + self.outfile.write("#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38\n") + self.outfile.write(" /* coverity[missing_lock : SUPPRESS] */\n") + self.outfile.write( + " g_clear_pointer (&skeleton->priv->changed_properties_idle_source, g_source_destroy);\n" + ) + self.outfile.write("#else\n") + self.outfile.write( " if (skeleton->priv->changed_properties_idle_source != NULL)\n" ) self.outfile.write( " g_source_destroy (skeleton->priv->changed_properties_idle_source);\n" ) + self.outfile.write("skeleton->priv->changed_properties_idle_source = NULL;\n") + + self.outfile.write("#endif\n") self.outfile.write(" g_main_context_unref (skeleton->priv->context);\n") self.outfile.write(" g_mutex_clear (&skeleton->priv->lock);\n") self.outfile.write(