[glib: 1/3] Fix compiler warning about uninitialized variable in giomodule
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/3] Fix compiler warning about uninitialized variable in giomodule
- Date: Thu, 24 Jan 2019 15:15:27 +0000 (UTC)
commit b4a5157f9586ef7bc808cc4da5abfd33d20b0883
Author: Sebastian Dröge <sebastian centricular com>
Date: Thu Jan 24 16:35:13 2019 +0200
Fix compiler warning about uninitialized variable in giomodule
It could've never been uninitialized in this code but the code flow is
not obvious to the compiler. Initialize it to NULL and for clarity also
add an assertion that it is not NULL anymore on usage.
In file included from ../glib/glib.h:62,
from ../gobject/gbinding.h:28,
from ../glib/glib-object.h:23,
from ../gio/gioenums.h:28,
from ../gio/giotypes.h:28,
from ../gio/giomodule.h:28,
from ../gio/giomodule.c:25:
../gio/giomodule.c: In function ‘_g_io_module_get_default’:
../glib/gmessages.h:343:25: warning: ‘extension’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
#define g_debug(...) g_log (G_LOG_DOMAIN, \
^~~~~
../gio/giomodule.c:912:17: note: ‘extension’ was declared here
GIOExtension *extension, *preferred;
^~~~~~~~~
gio/giomodule.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 52c60c210..b92162dcc 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -909,7 +909,7 @@ _g_io_module_get_default (const gchar *extension_point,
const char *use_this;
GList *l;
GIOExtensionPoint *ep;
- GIOExtension *extension, *preferred;
+ GIOExtension *extension = NULL, *preferred;
gpointer impl;
g_rec_mutex_lock (&default_modules_lock);
@@ -986,9 +986,12 @@ _g_io_module_get_default (const gchar *extension_point,
g_rec_mutex_unlock (&default_modules_lock);
if (impl != NULL)
- g_debug ("%s: Found default implementation %s (%s) for ‘%s’",
- G_STRFUNC, g_io_extension_get_name (extension),
- G_OBJECT_TYPE_NAME (impl), extension_point);
+ {
+ g_assert (extension != NULL);
+ g_debug ("%s: Found default implementation %s (%s) for ‘%s’",
+ G_STRFUNC, g_io_extension_get_name (extension),
+ G_OBJECT_TYPE_NAME (impl), extension_point);
+ }
else
g_debug ("%s: Failed to find default implementation for ‘%s’",
G_STRFUNC, extension_point);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]