summaryrefslogtreecommitdiff
path: root/shared/nm-glib-aux/nm-json-aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-glib-aux/nm-json-aux.c')
-rw-r--r--shared/nm-glib-aux/nm-json-aux.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/shared/nm-glib-aux/nm-json-aux.c b/shared/nm-glib-aux/nm-json-aux.c
index aba979d205..4758d2a1bd 100644
--- a/shared/nm-glib-aux/nm-json-aux.c
+++ b/shared/nm-glib-aux/nm-json-aux.c
@@ -147,26 +147,32 @@ static NMJsonVtInternal *
_nm_json_vt_internal_load (void)
{
NMJsonVtInternal *v;
- void *handle = NULL;
- int mode;
+ const char *soname;
+ void *handle;
v = g_new (NMJsonVtInternal, 1);
-
*v = (NMJsonVtInternal) { };
-#ifndef JANSSON_SONAME
-#define JANSSON_SONAME ""
-#endif
-
- mode = RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND;
-#if defined (ASAN_BUILD)
- /* Address sanitizer is incompatible with RTLD_DEEPBIND. */
- mode &= ~RTLD_DEEPBIND;
+#if WITH_JANSSON && defined (JANSSON_SONAME)
+ G_STATIC_ASSERT_EXPR (NM_STRLEN (JANSSON_SONAME) > 0);
+ nm_assert (strlen (JANSSON_SONAME) > 0);
+ soname = JANSSON_SONAME;
+#elif !WITH_JANSSON && !defined (JANSSON_SONAME)
+ soname = NULL;
+#else
+#error "WITH_JANSON and JANSSON_SONAME are defined inconsistently."
#endif
- if (strlen (JANSSON_SONAME) > 0)
- handle = dlopen (JANSSON_SONAME, mode);
+ if (!soname)
+ return v;
+ handle = dlopen (soname, RTLD_LAZY
+ | RTLD_LOCAL
+ | RTLD_NODELETE
+#if !defined (ASAN_BUILD)
+ | RTLD_DEEPBIND
+#endif
+ | 0);
if (!handle)
return v;