[PATCH] glib: guard invocations of g_type_init()

Ben Chan benchan at chromium.org
Fri Feb 3 00:46:09 UTC 2017


g_type_init() has been deprecated (and also marked with the attribute
'deprecated') since glib 2.36 as the type system is automatically
initialized. Since the minimum version of glib required by libmbim is
2.32, calling g_type_init() should be guarded with the
GLIB_CHECK_VERSION macro. When libmbim later requires at least glib
2.36, we can completely remove all invocations of g_type_init() from the
code.
---
 src/mbim-proxy/mbim-proxy.c | 2 ++
 src/mbimcli/mbimcli.c       | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/mbim-proxy/mbim-proxy.c b/src/mbim-proxy/mbim-proxy.c
index f29303f..2e8eeb9 100644
--- a/src/mbim-proxy/mbim-proxy.c
+++ b/src/mbim-proxy/mbim-proxy.c
@@ -196,7 +196,9 @@ int main (int argc, char **argv)
 
     setlocale (LC_ALL, "");
 
+#if !GLIB_CHECK_VERSION (2, 36, 0)
     g_type_init ();
+#endif
 
     /* Setup option context, process it and destroy it */
     context = g_option_context_new ("- Proxy for MBIM devices");
diff --git a/src/mbimcli/mbimcli.c b/src/mbimcli/mbimcli.c
index 9906693..a265895 100644
--- a/src/mbimcli/mbimcli.c
+++ b/src/mbimcli/mbimcli.c
@@ -372,7 +372,9 @@ int main (int argc, char **argv)
 
     setlocale (LC_ALL, "");
 
+#if !GLIB_CHECK_VERSION (2, 36, 0)
     g_type_init ();
+#endif
 
     /* Setup option context, process it and destroy it */
     context = g_option_context_new ("- Control MBIM devices");
-- 
2.11.0.483.g087da7b7c-goog



More information about the libmbim-devel mailing list