[PATCH] libosmocore[master]: gsm_utils: call gnutls_global_init() as constructor

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Wed May 2 13:26:52 UTC 2018


Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7904

to look at the new patch set (#4).

gsm_utils: call gnutls_global_init() as constructor

gnutls_global_init must be called at least once for
gnutls < 3.3.0. It doesn't hurt calling it twice, except
a reference counter is increased.
gnutls >= 3.3.0 will call it automatic.

Fixes: OS#2986
Change-Id: I241b6ae5aa8df13dd78f04658cf0953e9561c9e2
---
M src/gsm/gsm_utils.c
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/04/7904/4

diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c
index 5d8c834..47f3e2b 100644
--- a/src/gsm/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -112,6 +112,25 @@
 #pragma message ("including GnuTLS for getrandom fallback.")
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
+
+/* gnutls < 3.3.0 requires global init.
+ * gnutls >= 3.3.0 does it automatic.
+ * It doesn't hurt calling it twice,
+ * as long it's not done at the same time (threads).
+ */
+__attribute__((constructor))
+static void on_dso_load_gnutls(void)
+{
+	if (gnutls_check_version("3.3.0"))
+		gnutls_global_init();
+}
+
+__attribute__((destructor))
+static void on_dso_unload_gnutls(void)
+{
+	if (gnutls_check_version("3.3.0"))
+		gnutls_global_deinit();
+{
 #endif
 
 /* ETSI GSM 03.38 6.2.1 and 6.2.1.1 default alphabet

-- 
To view, visit https://gerrit.osmocom.org/7904
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I241b6ae5aa8df13dd78f04658cf0953e9561c9e2
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list