Blame SOURCES/0021-avoid-symbol-clash-with-json-glib-rh1535905.patch

c48088
From 66ae13f012a7416db839c6d6158b9c85cd9a27c5 Mon Sep 17 00:00:00 2001
c48088
From: Lubomir Rintel <lkundrak@v3.sk>
c48088
Date: Tue, 26 Dec 2017 09:28:54 +0100
c48088
Subject: [PATCH 1/6] core: load jansson on demand
c48088
c48088
Avoid using it if the symbols clash is detected.
c48088
c48088
(cherry picked from commit cd476e4dc922f0acfd65b02639032ee67339ad95)
c48088
---
c48088
 Makefile.am             |  12 +++--
c48088
 configure.ac            |  12 ++++-
c48088
 libnm-core/nm-jansson.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++
c48088
 libnm-core/nm-jansson.h |  46 +++++++++++++++++++
c48088
 libnm-core/nm-utils.c   |  78 +++++++++++++++++++------------
c48088
 5 files changed, 232 insertions(+), 35 deletions(-)
c48088
 create mode 100644 libnm-core/nm-jansson.c
c48088
 create mode 100644 libnm-core/nm-jansson.h
c48088
c48088
diff --git a/Makefile.am b/Makefile.am
c48088
index a189262c1..69d61c4fe 100644
c48088
--- a/Makefile.am
c48088
+++ b/Makefile.am
c48088
@@ -518,6 +518,14 @@ libnm_core_lib_c_real = \
c48088
 	libnm-core/nm-utils.c \
c48088
 	libnm-core/nm-vpn-editor-plugin.c \
c48088
 	libnm-core/nm-vpn-plugin-info.c
c48088
+
c48088
+if WITH_JANSSON
c48088
+libnm_core_lib_h_priv += \
c48088
+	libnm-core/nm-jansson.h
c48088
+libnm_core_lib_c_real += \
c48088
+	libnm-core/nm-jansson.c
c48088
+endif
c48088
+
c48088
 libnm_core_lib_c_mkenums = \
c48088
 	libnm-core/nm-core-enum-types.c
c48088
 
c48088
@@ -598,10 +606,6 @@ libnm_core_libnm_core_la_LIBADD = \
c48088
 	$(UUID_LIBS) \
c48088
 	$(LIBUDEV_LIBS)
c48088
 
c48088
-if WITH_JANSSON
c48088
-libnm_core_libnm_core_la_LIBADD += $(JANSSON_LIBS)
c48088
-endif
c48088
-
c48088
 libnm_core_libnm_core_la_LDFLAGS = \
c48088
 	$(CODE_COVERAGE_LDFLAGS)
c48088
 
c48088
diff --git a/configure.ac b/configure.ac
c48088
index 05ba94971..5b5090318 100644
c48088
--- a/configure.ac
c48088
+++ b/configure.ac
c48088
@@ -664,7 +664,17 @@ else
c48088
 	if test "$have_jansson" = "no"; then
c48088
 		AC_MSG_ERROR([jansson is needed for team configuration validation. Use --disable-json-validation to build without it.])
c48088
 	fi
c48088
-		AC_DEFINE(WITH_JANSSON, 1, [Define if JANSSON is enabled])
c48088
+
c48088
+	AC_DEFINE(WITH_JANSSON, 1, [Define if JANSSON is enabled])
c48088
+
c48088
+	AC_CHECK_TOOLS(READELF, [eu-readelf readelf])
c48088
+	JANSSON_LIBDIR=`$PKG_CONFIG --variable=libdir jansson`
c48088
+	JANSSON_SONAME=`$READELF -d $JANSSON_LIBDIR/libjansson.so |sed -n 's/.*SONAME.*\[[\([^]]*\)]]/\1/p'`
c48088
+
c48088
+	if test "$JANSSON_SONAME" = ""; then
c48088
+		AC_MSG_ERROR(Unable to locate the Jansson library)
c48088
+	fi
c48088
+	AC_DEFINE_UNQUOTED(JANSSON_SONAME, "$JANSSON_SONAME", [Define to path to the Jansson shared library])
c48088
 fi
c48088
 AM_CONDITIONAL(WITH_JANSSON, test "${enable_json_validation}" != "no")
c48088
 
c48088
diff --git a/libnm-core/nm-jansson.c b/libnm-core/nm-jansson.c
c48088
new file mode 100644
c48088
index 000000000..0f7bd3213
c48088
--- /dev/null
c48088
+++ b/libnm-core/nm-jansson.c
c48088
@@ -0,0 +1,119 @@
c48088
+/*
c48088
+ * This program is free software; you can redistribute it and/or modify
c48088
+ * it under the terms of the GNU General Public License as published by
c48088
+ * the Free Software Foundation; either version 2 of the License, or
c48088
+ * (at your option) any later version.
c48088
+ *
c48088
+ * This program is distributed in the hope that it will be useful,
c48088
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
+ * GNU General Public License for more details.
c48088
+ *
c48088
+ * You should have received a copy of the GNU General Public License along
c48088
+ * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
+ *
c48088
+ * Copyright 2017, 2018 Red Hat, Inc.
c48088
+ */
c48088
+
c48088
+#define _GNU_SOURCE
c48088
+#include <link.h>
c48088
+
c48088
+#include "nm-default.h"
c48088
+
c48088
+#define NM_JAONSSON_C
c48088
+#include "nm-jansson.h"
c48088
+
c48088
+void *_nm_jansson_json_object_iter_value;
c48088
+void *_nm_jansson_json_object_key_to_iter;
c48088
+void *_nm_jansson_json_integer;
c48088
+void *_nm_jansson_json_object_del;
c48088
+void *_nm_jansson_json_array_get;
c48088
+void *_nm_jansson_json_array_size;
c48088
+void *_nm_jansson_json_array_append_new;
c48088
+void *_nm_jansson_json_string;
c48088
+void *_nm_jansson_json_object_iter_next;
c48088
+void *_nm_jansson_json_loads;
c48088
+void *_nm_jansson_json_dumps;
c48088
+void *_nm_jansson_json_object_iter_key;
c48088
+void *_nm_jansson_json_object;
c48088
+void *_nm_jansson_json_object_get;
c48088
+void *_nm_jansson_json_array;
c48088
+void *_nm_jansson_json_false;
c48088
+void *_nm_jansson_json_delete;
c48088
+void *_nm_jansson_json_true;
c48088
+void *_nm_jansson_json_object_size;
c48088
+void *_nm_jansson_json_object_set_new;
c48088
+void *_nm_jansson_json_object_iter;
c48088
+void *_nm_jansson_json_object_iter_at;
c48088
+void *_nm_jansson_json_integer_value;
c48088
+void *_nm_jansson_json_string_value;
c48088
+
c48088
+#define TRY_BIND_SYMBOL(symbol) \
c48088
+	G_STMT_START { \
c48088
+		void *sym = dlsym (handle, #symbol); \
c48088
+		if (_nm_jansson_ ## symbol && sym != _nm_jansson_ ## symbol) \
c48088
+			return FALSE; \
c48088
+		_nm_jansson_ ## symbol = sym; \
c48088
+	} G_STMT_END
c48088
+
c48088
+static gboolean
c48088
+bind_symbols (void *handle)
c48088
+{
c48088
+	TRY_BIND_SYMBOL (json_object_iter_value);
c48088
+	TRY_BIND_SYMBOL (json_object_key_to_iter);
c48088
+	TRY_BIND_SYMBOL (json_integer);
c48088
+	TRY_BIND_SYMBOL (json_object_del);
c48088
+	TRY_BIND_SYMBOL (json_array_get);
c48088
+	TRY_BIND_SYMBOL (json_array_size);
c48088
+	TRY_BIND_SYMBOL (json_array_append_new);
c48088
+	TRY_BIND_SYMBOL (json_string);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_next);
c48088
+	TRY_BIND_SYMBOL (json_loads);
c48088
+	TRY_BIND_SYMBOL (json_dumps);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_key);
c48088
+	TRY_BIND_SYMBOL (json_object);
c48088
+	TRY_BIND_SYMBOL (json_object_get);
c48088
+	TRY_BIND_SYMBOL (json_array);
c48088
+	TRY_BIND_SYMBOL (json_false);
c48088
+	TRY_BIND_SYMBOL (json_delete);
c48088
+	TRY_BIND_SYMBOL (json_true);
c48088
+	TRY_BIND_SYMBOL (json_object_size);
c48088
+	TRY_BIND_SYMBOL (json_object_set_new);
c48088
+	TRY_BIND_SYMBOL (json_object_iter);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_at);
c48088
+	TRY_BIND_SYMBOL (json_integer_value);
c48088
+	TRY_BIND_SYMBOL (json_string_value);
c48088
+
c48088
+	return TRUE;
c48088
+}
c48088
+
c48088
+gboolean
c48088
+nm_jansson_load (void)
c48088
+{
c48088
+	static enum {
c48088
+		UNKNOWN,
c48088
+		AVAILABLE,
c48088
+		MISSING,
c48088
+	} state = UNKNOWN;
c48088
+	void *handle;
c48088
+
c48088
+	if (G_LIKELY (state != UNKNOWN))
c48088
+		goto out;
c48088
+
c48088
+	/* First just resolve the symbols to see if there's a conflict already. */
c48088
+	if (!bind_symbols (RTLD_DEFAULT))
c48088
+		goto out;
c48088
+
c48088
+	handle = dlopen (JANSSON_SONAME, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND);
c48088
+	if (!handle)
c48088
+		goto out;
c48088
+
c48088
+	/* Now do the actual binding. */
c48088
+	if (!bind_symbols (handle))
c48088
+		goto out;
c48088
+
c48088
+	state = AVAILABLE;
c48088
+out:
c48088
+	return state == AVAILABLE;
c48088
+}
c48088
diff --git a/libnm-core/nm-jansson.h b/libnm-core/nm-jansson.h
c48088
new file mode 100644
c48088
index 000000000..043986878
c48088
--- /dev/null
c48088
+++ b/libnm-core/nm-jansson.h
c48088
@@ -0,0 +1,46 @@
c48088
+/*
c48088
+ * This program is free software; you can redistribute it and/or modify
c48088
+ * it under the terms of the GNU General Public License as published by
c48088
+ * the Free Software Foundation; either version 2 of the License, or
c48088
+ * (at your option) any later version.
c48088
+ *
c48088
+ * This program is distributed in the hope that it will be useful,
c48088
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
+ * GNU General Public License for more details.
c48088
+ *
c48088
+ * You should have received a copy of the GNU General Public License along
c48088
+ * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
+ *
c48088
+ * Copyright 2017, 2018 Red Hat, Inc.
c48088
+ */
c48088
+
c48088
+gboolean nm_jansson_load (void);
c48088
+
c48088
+#ifndef NM_JAONSSON_C
c48088
+#define json_object_iter_value	(*_nm_jansson_json_object_iter_value)
c48088
+#define json_object_key_to_iter	(*_nm_jansson_json_object_key_to_iter)
c48088
+#define json_integer		(*_nm_jansson_json_integer)
c48088
+#define json_object_del		(*_nm_jansson_json_object_del)
c48088
+#define json_array_get		(*_nm_jansson_json_array_get)
c48088
+#define json_array_size		(*_nm_jansson_json_array_size)
c48088
+#define json_array_append_new	(*_nm_jansson_json_array_append_new)
c48088
+#define json_string		(*_nm_jansson_json_string)
c48088
+#define json_object_iter_next	(*_nm_jansson_json_object_iter_next)
c48088
+#define json_loads		(*_nm_jansson_json_loads)
c48088
+#define json_dumps		(*_nm_jansson_json_dumps)
c48088
+#define json_object_iter_key	(*_nm_jansson_json_object_iter_key)
c48088
+#define json_object		(*_nm_jansson_json_object)
c48088
+#define json_object_get		(*_nm_jansson_json_object_get)
c48088
+#define json_array		(*_nm_jansson_json_array)
c48088
+#define json_false		(*_nm_jansson_json_false)
c48088
+#define json_delete		(*_nm_jansson_json_delete)
c48088
+#define json_true		(*_nm_jansson_json_true)
c48088
+#define json_object_size	(*_nm_jansson_json_object_size)
c48088
+#define json_object_set_new	(*_nm_jansson_json_object_set_new)
c48088
+#define json_object_iter	(*_nm_jansson_json_object_iter)
c48088
+#define json_object_iter_at	(*_nm_jansson_json_object_iter_at)
c48088
+#define json_integer_value	(*_nm_jansson_json_integer_value)
c48088
+#define json_string_value	(*_nm_jansson_json_string_value)
c48088
+#endif
c48088
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
c48088
index ce3536c84..8d7bf08f9 100644
c48088
--- a/libnm-core/nm-utils.c
c48088
+++ b/libnm-core/nm-utils.c
c48088
@@ -36,6 +36,7 @@
c48088
 #include <linux/pkt_sched.h>
c48088
 
c48088
 #if WITH_JANSSON
c48088
+#include "nm-jansson.h"
c48088
 #include <jansson.h>
c48088
 #endif
c48088
 
c48088
@@ -4891,6 +4892,41 @@ const char **nm_utils_enum_get_values (GType type, gint from, gint to)
c48088
 
c48088
 /*****************************************************************************/
c48088
 
c48088
+static gboolean
c48088
+_nm_utils_is_json_object_no_validation (const char *str, GError **error)
c48088
+{
c48088
+	if (str) {
c48088
+		/* libjansson also requires only utf-8 encoding. */
c48088
+		if (!g_utf8_validate (str, -1, NULL)) {
c48088
+			g_set_error_literal (error,
c48088
+			                     NM_CONNECTION_ERROR,
c48088
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
c48088
+			                     _("not valid utf-8"));
c48088
+			return FALSE;
c48088
+		}
c48088
+		while (g_ascii_isspace (str[0]))
c48088
+			str++;
c48088
+	}
c48088
+
c48088
+	/* do some very basic validation to see if this might be a JSON object. */
c48088
+	if (str[0] == '{') {
c48088
+		gsize l;
c48088
+
c48088
+		l = strlen (str) - 1;
c48088
+		while (l > 0 && g_ascii_isspace (str[l]))
c48088
+			l--;
c48088
+
c48088
+		if (str[l] == '}')
c48088
+			return TRUE;
c48088
+	}
c48088
+
c48088
+	g_set_error_literal (error,
c48088
+	                     NM_CONNECTION_ERROR,
c48088
+	                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
c48088
+	                     _("is not a JSON object"));
c48088
+	return FALSE;
c48088
+}
c48088
+
c48088
 #if WITH_JANSSON
c48088
 
c48088
 /* Added in Jansson v2.3 (released Jan 27 2012) */
c48088
@@ -5363,6 +5399,9 @@ nm_utils_is_json_object (const char *str, GError **error)
c48088
 		return FALSE;
c48088
 	}
c48088
 
c48088
+	if (!nm_jansson_load ())
c48088
+		return _nm_utils_is_json_object_no_validation (str, error);
c48088
+
c48088
 	json = json_loads (str, JSON_REJECT_DUPLICATES, &jerror);
c48088
 	if (!json) {
c48088
 		g_set_error (error,
c48088
@@ -5413,6 +5452,8 @@ _nm_utils_team_config_equal (const char *conf1,
c48088
 
c48088
 	if (nm_streq0 (conf1, conf2))
c48088
 		return TRUE;
c48088
+	else if (!nm_jansson_load ())
c48088
+		return FALSE;
c48088
 
c48088
 	/* A NULL configuration is equivalent to default value '{}' */
c48088
 	json1 = json_loads (conf1 ?: "{}", JSON_REJECT_DUPLICATES, &jerror);
c48088
@@ -5470,6 +5511,9 @@ _nm_utils_team_config_get (const char *conf,
c48088
 	if (!key)
c48088
 		return NULL;
c48088
 
c48088
+	if (!nm_jansson_load ())
c48088
+		return NULL;
c48088
+
c48088
 	json = json_loads (conf ?: "{}", JSON_REJECT_DUPLICATES, &jerror);
c48088
 
c48088
 	/* Invalid json in conf */
c48088
@@ -5577,6 +5621,9 @@ _nm_utils_team_config_set (char **conf,
c48088
 
c48088
 	g_return_val_if_fail (key, FALSE);
c48088
 
c48088
+	if (!nm_jansson_load ())
c48088
+		return FALSE;
c48088
+
c48088
 	json = json_loads (*conf?: "{}", JSON_REJECT_DUPLICATES, &jerror);
c48088
 	if (!json)
c48088
 		return FALSE;
c48088
@@ -5694,19 +5741,6 @@ nm_utils_is_json_object (const char *str, GError **error)
c48088
 {
c48088
 	g_return_val_if_fail (!error || !*error, FALSE);
c48088
 
c48088
-	if (str) {
c48088
-		/* libjansson also requires only utf-8 encoding. */
c48088
-		if (!g_utf8_validate (str, -1, NULL)) {
c48088
-			g_set_error_literal (error,
c48088
-			                     NM_CONNECTION_ERROR,
c48088
-			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
c48088
-			                     _("not valid utf-8"));
c48088
-			return FALSE;
c48088
-		}
c48088
-		while (g_ascii_isspace (str[0]))
c48088
-			str++;
c48088
-	}
c48088
-
c48088
 	if (!str || !str[0]) {
c48088
 		g_set_error_literal (error,
c48088
 		                     NM_CONNECTION_ERROR,
c48088
@@ -5715,23 +5749,7 @@ nm_utils_is_json_object (const char *str, GError **error)
c48088
 		return FALSE;
c48088
 	}
c48088
 
c48088
-	/* do some very basic validation to see if this might be a JSON object. */
c48088
-	if (str[0] == '{') {
c48088
-		gsize l;
c48088
-
c48088
-		l = strlen (str) - 1;
c48088
-		while (l > 0 && g_ascii_isspace (str[l]))
c48088
-			l--;
c48088
-
c48088
-		if (str[l] == '}')
c48088
-			return TRUE;
c48088
-	}
c48088
-
c48088
-	g_set_error_literal (error,
c48088
-	                     NM_CONNECTION_ERROR,
c48088
-	                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
c48088
-	                     _("is not a JSON object"));
c48088
-	return FALSE;
c48088
+	return _nm_utils_is_json_object_no_validation (str, error);
c48088
 }
c48088
 
c48088
 gboolean
c48088
-- 
c48088
2.14.3
c48088
c48088
c48088
From 75dfbfcef40c44b2a04779351d0974b5e36818c2 Mon Sep 17 00:00:00 2001
c48088
From: Thomas Haller <thaller@redhat.com>
c48088
Date: Tue, 9 Jan 2018 07:10:24 +0100
c48088
Subject: [PATCH 2/6] libnm/trivial: don't use non-leading tabs
c48088
c48088
(cherry picked from commit 950a14128bc249626af0770f0003cf83d491bd54)
c48088
---
c48088
 libnm-core/nm-jansson.h | 48 ++++++++++++++++++++++++------------------------
c48088
 1 file changed, 24 insertions(+), 24 deletions(-)
c48088
c48088
diff --git a/libnm-core/nm-jansson.h b/libnm-core/nm-jansson.h
c48088
index 043986878..e3718d93c 100644
c48088
--- a/libnm-core/nm-jansson.h
c48088
+++ b/libnm-core/nm-jansson.h
c48088
@@ -19,28 +19,28 @@
c48088
 gboolean nm_jansson_load (void);
c48088
 
c48088
 #ifndef NM_JAONSSON_C
c48088
-#define json_object_iter_value	(*_nm_jansson_json_object_iter_value)
c48088
-#define json_object_key_to_iter	(*_nm_jansson_json_object_key_to_iter)
c48088
-#define json_integer		(*_nm_jansson_json_integer)
c48088
-#define json_object_del		(*_nm_jansson_json_object_del)
c48088
-#define json_array_get		(*_nm_jansson_json_array_get)
c48088
-#define json_array_size		(*_nm_jansson_json_array_size)
c48088
-#define json_array_append_new	(*_nm_jansson_json_array_append_new)
c48088
-#define json_string		(*_nm_jansson_json_string)
c48088
-#define json_object_iter_next	(*_nm_jansson_json_object_iter_next)
c48088
-#define json_loads		(*_nm_jansson_json_loads)
c48088
-#define json_dumps		(*_nm_jansson_json_dumps)
c48088
-#define json_object_iter_key	(*_nm_jansson_json_object_iter_key)
c48088
-#define json_object		(*_nm_jansson_json_object)
c48088
-#define json_object_get		(*_nm_jansson_json_object_get)
c48088
-#define json_array		(*_nm_jansson_json_array)
c48088
-#define json_false		(*_nm_jansson_json_false)
c48088
-#define json_delete		(*_nm_jansson_json_delete)
c48088
-#define json_true		(*_nm_jansson_json_true)
c48088
-#define json_object_size	(*_nm_jansson_json_object_size)
c48088
-#define json_object_set_new	(*_nm_jansson_json_object_set_new)
c48088
-#define json_object_iter	(*_nm_jansson_json_object_iter)
c48088
-#define json_object_iter_at	(*_nm_jansson_json_object_iter_at)
c48088
-#define json_integer_value	(*_nm_jansson_json_integer_value)
c48088
-#define json_string_value	(*_nm_jansson_json_string_value)
c48088
+#define json_object_iter_value  (*_nm_jansson_json_object_iter_value)
c48088
+#define json_object_key_to_iter (*_nm_jansson_json_object_key_to_iter)
c48088
+#define json_integer            (*_nm_jansson_json_integer)
c48088
+#define json_object_del         (*_nm_jansson_json_object_del)
c48088
+#define json_array_get          (*_nm_jansson_json_array_get)
c48088
+#define json_array_size         (*_nm_jansson_json_array_size)
c48088
+#define json_array_append_new   (*_nm_jansson_json_array_append_new)
c48088
+#define json_string             (*_nm_jansson_json_string)
c48088
+#define json_object_iter_next   (*_nm_jansson_json_object_iter_next)
c48088
+#define json_loads              (*_nm_jansson_json_loads)
c48088
+#define json_dumps              (*_nm_jansson_json_dumps)
c48088
+#define json_object_iter_key    (*_nm_jansson_json_object_iter_key)
c48088
+#define json_object             (*_nm_jansson_json_object)
c48088
+#define json_object_get         (*_nm_jansson_json_object_get)
c48088
+#define json_array              (*_nm_jansson_json_array)
c48088
+#define json_false              (*_nm_jansson_json_false)
c48088
+#define json_delete             (*_nm_jansson_json_delete)
c48088
+#define json_true               (*_nm_jansson_json_true)
c48088
+#define json_object_size        (*_nm_jansson_json_object_size)
c48088
+#define json_object_set_new     (*_nm_jansson_json_object_set_new)
c48088
+#define json_object_iter        (*_nm_jansson_json_object_iter)
c48088
+#define json_object_iter_at     (*_nm_jansson_json_object_iter_at)
c48088
+#define json_integer_value      (*_nm_jansson_json_integer_value)
c48088
+#define json_string_value       (*_nm_jansson_json_string_value)
c48088
 #endif
c48088
-- 
c48088
2.14.3
c48088
c48088
c48088
From bbcb9ebefcffab302d192dcd60c084c2698dff24 Mon Sep 17 00:00:00 2001
c48088
From: Thomas Haller <thaller@redhat.com>
c48088
Date: Tue, 9 Jan 2018 06:20:18 +0100
c48088
Subject: [PATCH 3/6] libnm: rename "libnm-core/nm-jansson.h" to
c48088
 "libnm-core/nm-json.h"
c48088
c48088
We already have "shared/nm-utils/nm-jansson.h". Avoid reusing the same file name.
c48088
c48088
(cherry picked from commit b6b6baa7735e09a95fa9504e9a9746cdc4e970e6)
c48088
---
c48088
 Makefile.am             |   4 +-
c48088
 libnm-core/nm-jansson.c | 119 ------------------------------------------------
c48088
 libnm-core/nm-jansson.h |  46 -------------------
c48088
 libnm-core/nm-json.c    | 119 ++++++++++++++++++++++++++++++++++++++++++++++++
c48088
 libnm-core/nm-json.h    |  46 +++++++++++++++++++
c48088
 libnm-core/nm-utils.c   |   2 +-
c48088
 6 files changed, 168 insertions(+), 168 deletions(-)
c48088
 delete mode 100644 libnm-core/nm-jansson.c
c48088
 delete mode 100644 libnm-core/nm-jansson.h
c48088
 create mode 100644 libnm-core/nm-json.c
c48088
 create mode 100644 libnm-core/nm-json.h
c48088
c48088
diff --git a/Makefile.am b/Makefile.am
c48088
index 69d61c4fe..639921d50 100644
c48088
--- a/Makefile.am
c48088
+++ b/Makefile.am
c48088
@@ -521,9 +521,9 @@ libnm_core_lib_c_real = \
c48088
 
c48088
 if WITH_JANSSON
c48088
 libnm_core_lib_h_priv += \
c48088
-	libnm-core/nm-jansson.h
c48088
+	libnm-core/nm-json.h
c48088
 libnm_core_lib_c_real += \
c48088
-	libnm-core/nm-jansson.c
c48088
+	libnm-core/nm-json.c
c48088
 endif
c48088
 
c48088
 libnm_core_lib_c_mkenums = \
c48088
diff --git a/libnm-core/nm-jansson.c b/libnm-core/nm-jansson.c
c48088
deleted file mode 100644
c48088
index 0f7bd3213..000000000
c48088
--- a/libnm-core/nm-jansson.c
c48088
+++ /dev/null
c48088
@@ -1,119 +0,0 @@
c48088
-/*
c48088
- * This program is free software; you can redistribute it and/or modify
c48088
- * it under the terms of the GNU General Public License as published by
c48088
- * the Free Software Foundation; either version 2 of the License, or
c48088
- * (at your option) any later version.
c48088
- *
c48088
- * This program is distributed in the hope that it will be useful,
c48088
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
- * GNU General Public License for more details.
c48088
- *
c48088
- * You should have received a copy of the GNU General Public License along
c48088
- * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
- *
c48088
- * Copyright 2017, 2018 Red Hat, Inc.
c48088
- */
c48088
-
c48088
-#define _GNU_SOURCE
c48088
-#include <link.h>
c48088
-
c48088
-#include "nm-default.h"
c48088
-
c48088
-#define NM_JAONSSON_C
c48088
-#include "nm-jansson.h"
c48088
-
c48088
-void *_nm_jansson_json_object_iter_value;
c48088
-void *_nm_jansson_json_object_key_to_iter;
c48088
-void *_nm_jansson_json_integer;
c48088
-void *_nm_jansson_json_object_del;
c48088
-void *_nm_jansson_json_array_get;
c48088
-void *_nm_jansson_json_array_size;
c48088
-void *_nm_jansson_json_array_append_new;
c48088
-void *_nm_jansson_json_string;
c48088
-void *_nm_jansson_json_object_iter_next;
c48088
-void *_nm_jansson_json_loads;
c48088
-void *_nm_jansson_json_dumps;
c48088
-void *_nm_jansson_json_object_iter_key;
c48088
-void *_nm_jansson_json_object;
c48088
-void *_nm_jansson_json_object_get;
c48088
-void *_nm_jansson_json_array;
c48088
-void *_nm_jansson_json_false;
c48088
-void *_nm_jansson_json_delete;
c48088
-void *_nm_jansson_json_true;
c48088
-void *_nm_jansson_json_object_size;
c48088
-void *_nm_jansson_json_object_set_new;
c48088
-void *_nm_jansson_json_object_iter;
c48088
-void *_nm_jansson_json_object_iter_at;
c48088
-void *_nm_jansson_json_integer_value;
c48088
-void *_nm_jansson_json_string_value;
c48088
-
c48088
-#define TRY_BIND_SYMBOL(symbol) \
c48088
-	G_STMT_START { \
c48088
-		void *sym = dlsym (handle, #symbol); \
c48088
-		if (_nm_jansson_ ## symbol && sym != _nm_jansson_ ## symbol) \
c48088
-			return FALSE; \
c48088
-		_nm_jansson_ ## symbol = sym; \
c48088
-	} G_STMT_END
c48088
-
c48088
-static gboolean
c48088
-bind_symbols (void *handle)
c48088
-{
c48088
-	TRY_BIND_SYMBOL (json_object_iter_value);
c48088
-	TRY_BIND_SYMBOL (json_object_key_to_iter);
c48088
-	TRY_BIND_SYMBOL (json_integer);
c48088
-	TRY_BIND_SYMBOL (json_object_del);
c48088
-	TRY_BIND_SYMBOL (json_array_get);
c48088
-	TRY_BIND_SYMBOL (json_array_size);
c48088
-	TRY_BIND_SYMBOL (json_array_append_new);
c48088
-	TRY_BIND_SYMBOL (json_string);
c48088
-	TRY_BIND_SYMBOL (json_object_iter_next);
c48088
-	TRY_BIND_SYMBOL (json_loads);
c48088
-	TRY_BIND_SYMBOL (json_dumps);
c48088
-	TRY_BIND_SYMBOL (json_object_iter_key);
c48088
-	TRY_BIND_SYMBOL (json_object);
c48088
-	TRY_BIND_SYMBOL (json_object_get);
c48088
-	TRY_BIND_SYMBOL (json_array);
c48088
-	TRY_BIND_SYMBOL (json_false);
c48088
-	TRY_BIND_SYMBOL (json_delete);
c48088
-	TRY_BIND_SYMBOL (json_true);
c48088
-	TRY_BIND_SYMBOL (json_object_size);
c48088
-	TRY_BIND_SYMBOL (json_object_set_new);
c48088
-	TRY_BIND_SYMBOL (json_object_iter);
c48088
-	TRY_BIND_SYMBOL (json_object_iter_at);
c48088
-	TRY_BIND_SYMBOL (json_integer_value);
c48088
-	TRY_BIND_SYMBOL (json_string_value);
c48088
-
c48088
-	return TRUE;
c48088
-}
c48088
-
c48088
-gboolean
c48088
-nm_jansson_load (void)
c48088
-{
c48088
-	static enum {
c48088
-		UNKNOWN,
c48088
-		AVAILABLE,
c48088
-		MISSING,
c48088
-	} state = UNKNOWN;
c48088
-	void *handle;
c48088
-
c48088
-	if (G_LIKELY (state != UNKNOWN))
c48088
-		goto out;
c48088
-
c48088
-	/* First just resolve the symbols to see if there's a conflict already. */
c48088
-	if (!bind_symbols (RTLD_DEFAULT))
c48088
-		goto out;
c48088
-
c48088
-	handle = dlopen (JANSSON_SONAME, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND);
c48088
-	if (!handle)
c48088
-		goto out;
c48088
-
c48088
-	/* Now do the actual binding. */
c48088
-	if (!bind_symbols (handle))
c48088
-		goto out;
c48088
-
c48088
-	state = AVAILABLE;
c48088
-out:
c48088
-	return state == AVAILABLE;
c48088
-}
c48088
diff --git a/libnm-core/nm-jansson.h b/libnm-core/nm-jansson.h
c48088
deleted file mode 100644
c48088
index e3718d93c..000000000
c48088
--- a/libnm-core/nm-jansson.h
c48088
+++ /dev/null
c48088
@@ -1,46 +0,0 @@
c48088
-/*
c48088
- * This program is free software; you can redistribute it and/or modify
c48088
- * it under the terms of the GNU General Public License as published by
c48088
- * the Free Software Foundation; either version 2 of the License, or
c48088
- * (at your option) any later version.
c48088
- *
c48088
- * This program is distributed in the hope that it will be useful,
c48088
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
- * GNU General Public License for more details.
c48088
- *
c48088
- * You should have received a copy of the GNU General Public License along
c48088
- * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
- *
c48088
- * Copyright 2017, 2018 Red Hat, Inc.
c48088
- */
c48088
-
c48088
-gboolean nm_jansson_load (void);
c48088
-
c48088
-#ifndef NM_JAONSSON_C
c48088
-#define json_object_iter_value  (*_nm_jansson_json_object_iter_value)
c48088
-#define json_object_key_to_iter (*_nm_jansson_json_object_key_to_iter)
c48088
-#define json_integer            (*_nm_jansson_json_integer)
c48088
-#define json_object_del         (*_nm_jansson_json_object_del)
c48088
-#define json_array_get          (*_nm_jansson_json_array_get)
c48088
-#define json_array_size         (*_nm_jansson_json_array_size)
c48088
-#define json_array_append_new   (*_nm_jansson_json_array_append_new)
c48088
-#define json_string             (*_nm_jansson_json_string)
c48088
-#define json_object_iter_next   (*_nm_jansson_json_object_iter_next)
c48088
-#define json_loads              (*_nm_jansson_json_loads)
c48088
-#define json_dumps              (*_nm_jansson_json_dumps)
c48088
-#define json_object_iter_key    (*_nm_jansson_json_object_iter_key)
c48088
-#define json_object             (*_nm_jansson_json_object)
c48088
-#define json_object_get         (*_nm_jansson_json_object_get)
c48088
-#define json_array              (*_nm_jansson_json_array)
c48088
-#define json_false              (*_nm_jansson_json_false)
c48088
-#define json_delete             (*_nm_jansson_json_delete)
c48088
-#define json_true               (*_nm_jansson_json_true)
c48088
-#define json_object_size        (*_nm_jansson_json_object_size)
c48088
-#define json_object_set_new     (*_nm_jansson_json_object_set_new)
c48088
-#define json_object_iter        (*_nm_jansson_json_object_iter)
c48088
-#define json_object_iter_at     (*_nm_jansson_json_object_iter_at)
c48088
-#define json_integer_value      (*_nm_jansson_json_integer_value)
c48088
-#define json_string_value       (*_nm_jansson_json_string_value)
c48088
-#endif
c48088
diff --git a/libnm-core/nm-json.c b/libnm-core/nm-json.c
c48088
new file mode 100644
c48088
index 000000000..1f7d4398a
c48088
--- /dev/null
c48088
+++ b/libnm-core/nm-json.c
c48088
@@ -0,0 +1,119 @@
c48088
+/*
c48088
+ * This program is free software; you can redistribute it and/or modify
c48088
+ * it under the terms of the GNU General Public License as published by
c48088
+ * the Free Software Foundation; either version 2 of the License, or
c48088
+ * (at your option) any later version.
c48088
+ *
c48088
+ * This program is distributed in the hope that it will be useful,
c48088
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
+ * GNU General Public License for more details.
c48088
+ *
c48088
+ * You should have received a copy of the GNU General Public License along
c48088
+ * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
+ *
c48088
+ * Copyright 2017, 2018 Red Hat, Inc.
c48088
+ */
c48088
+
c48088
+#define _GNU_SOURCE
c48088
+#include <link.h>
c48088
+
c48088
+#include "nm-default.h"
c48088
+
c48088
+#define NM_JAONSSON_C
c48088
+#include "nm-json.h"
c48088
+
c48088
+void *_nm_jansson_json_object_iter_value;
c48088
+void *_nm_jansson_json_object_key_to_iter;
c48088
+void *_nm_jansson_json_integer;
c48088
+void *_nm_jansson_json_object_del;
c48088
+void *_nm_jansson_json_array_get;
c48088
+void *_nm_jansson_json_array_size;
c48088
+void *_nm_jansson_json_array_append_new;
c48088
+void *_nm_jansson_json_string;
c48088
+void *_nm_jansson_json_object_iter_next;
c48088
+void *_nm_jansson_json_loads;
c48088
+void *_nm_jansson_json_dumps;
c48088
+void *_nm_jansson_json_object_iter_key;
c48088
+void *_nm_jansson_json_object;
c48088
+void *_nm_jansson_json_object_get;
c48088
+void *_nm_jansson_json_array;
c48088
+void *_nm_jansson_json_false;
c48088
+void *_nm_jansson_json_delete;
c48088
+void *_nm_jansson_json_true;
c48088
+void *_nm_jansson_json_object_size;
c48088
+void *_nm_jansson_json_object_set_new;
c48088
+void *_nm_jansson_json_object_iter;
c48088
+void *_nm_jansson_json_object_iter_at;
c48088
+void *_nm_jansson_json_integer_value;
c48088
+void *_nm_jansson_json_string_value;
c48088
+
c48088
+#define TRY_BIND_SYMBOL(symbol) \
c48088
+	G_STMT_START { \
c48088
+		void *sym = dlsym (handle, #symbol); \
c48088
+		if (_nm_jansson_ ## symbol && sym != _nm_jansson_ ## symbol) \
c48088
+			return FALSE; \
c48088
+		_nm_jansson_ ## symbol = sym; \
c48088
+	} G_STMT_END
c48088
+
c48088
+static gboolean
c48088
+bind_symbols (void *handle)
c48088
+{
c48088
+	TRY_BIND_SYMBOL (json_object_iter_value);
c48088
+	TRY_BIND_SYMBOL (json_object_key_to_iter);
c48088
+	TRY_BIND_SYMBOL (json_integer);
c48088
+	TRY_BIND_SYMBOL (json_object_del);
c48088
+	TRY_BIND_SYMBOL (json_array_get);
c48088
+	TRY_BIND_SYMBOL (json_array_size);
c48088
+	TRY_BIND_SYMBOL (json_array_append_new);
c48088
+	TRY_BIND_SYMBOL (json_string);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_next);
c48088
+	TRY_BIND_SYMBOL (json_loads);
c48088
+	TRY_BIND_SYMBOL (json_dumps);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_key);
c48088
+	TRY_BIND_SYMBOL (json_object);
c48088
+	TRY_BIND_SYMBOL (json_object_get);
c48088
+	TRY_BIND_SYMBOL (json_array);
c48088
+	TRY_BIND_SYMBOL (json_false);
c48088
+	TRY_BIND_SYMBOL (json_delete);
c48088
+	TRY_BIND_SYMBOL (json_true);
c48088
+	TRY_BIND_SYMBOL (json_object_size);
c48088
+	TRY_BIND_SYMBOL (json_object_set_new);
c48088
+	TRY_BIND_SYMBOL (json_object_iter);
c48088
+	TRY_BIND_SYMBOL (json_object_iter_at);
c48088
+	TRY_BIND_SYMBOL (json_integer_value);
c48088
+	TRY_BIND_SYMBOL (json_string_value);
c48088
+
c48088
+	return TRUE;
c48088
+}
c48088
+
c48088
+gboolean
c48088
+nm_jansson_load (void)
c48088
+{
c48088
+	static enum {
c48088
+		UNKNOWN,
c48088
+		AVAILABLE,
c48088
+		MISSING,
c48088
+	} state = UNKNOWN;
c48088
+	void *handle;
c48088
+
c48088
+	if (G_LIKELY (state != UNKNOWN))
c48088
+		goto out;
c48088
+
c48088
+	/* First just resolve the symbols to see if there's a conflict already. */
c48088
+	if (!bind_symbols (RTLD_DEFAULT))
c48088
+		goto out;
c48088
+
c48088
+	handle = dlopen (JANSSON_SONAME, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND);
c48088
+	if (!handle)
c48088
+		goto out;
c48088
+
c48088
+	/* Now do the actual binding. */
c48088
+	if (!bind_symbols (handle))
c48088
+		goto out;
c48088
+
c48088
+	state = AVAILABLE;
c48088
+out:
c48088
+	return state == AVAILABLE;
c48088
+}
c48088
diff --git a/libnm-core/nm-json.h b/libnm-core/nm-json.h
c48088
new file mode 100644
c48088
index 000000000..e3718d93c
c48088
--- /dev/null
c48088
+++ b/libnm-core/nm-json.h
c48088
@@ -0,0 +1,46 @@
c48088
+/*
c48088
+ * This program is free software; you can redistribute it and/or modify
c48088
+ * it under the terms of the GNU General Public License as published by
c48088
+ * the Free Software Foundation; either version 2 of the License, or
c48088
+ * (at your option) any later version.
c48088
+ *
c48088
+ * This program is distributed in the hope that it will be useful,
c48088
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c48088
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c48088
+ * GNU General Public License for more details.
c48088
+ *
c48088
+ * You should have received a copy of the GNU General Public License along
c48088
+ * with this program; if not, write to the Free Software Foundation, Inc.,
c48088
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c48088
+ *
c48088
+ * Copyright 2017, 2018 Red Hat, Inc.
c48088
+ */
c48088
+
c48088
+gboolean nm_jansson_load (void);
c48088
+
c48088
+#ifndef NM_JAONSSON_C
c48088
+#define json_object_iter_value  (*_nm_jansson_json_object_iter_value)
c48088
+#define json_object_key_to_iter (*_nm_jansson_json_object_key_to_iter)
c48088
+#define json_integer            (*_nm_jansson_json_integer)
c48088
+#define json_object_del         (*_nm_jansson_json_object_del)
c48088
+#define json_array_get          (*_nm_jansson_json_array_get)
c48088
+#define json_array_size         (*_nm_jansson_json_array_size)
c48088
+#define json_array_append_new   (*_nm_jansson_json_array_append_new)
c48088
+#define json_string             (*_nm_jansson_json_string)
c48088
+#define json_object_iter_next   (*_nm_jansson_json_object_iter_next)
c48088
+#define json_loads              (*_nm_jansson_json_loads)
c48088
+#define json_dumps              (*_nm_jansson_json_dumps)
c48088
+#define json_object_iter_key    (*_nm_jansson_json_object_iter_key)
c48088
+#define json_object             (*_nm_jansson_json_object)
c48088
+#define json_object_get         (*_nm_jansson_json_object_get)
c48088
+#define json_array              (*_nm_jansson_json_array)
c48088
+#define json_false              (*_nm_jansson_json_false)
c48088
+#define json_delete             (*_nm_jansson_json_delete)
c48088
+#define json_true               (*_nm_jansson_json_true)
c48088
+#define json_object_size        (*_nm_jansson_json_object_size)
c48088
+#define json_object_set_new     (*_nm_jansson_json_object_set_new)
c48088
+#define json_object_iter        (*_nm_jansson_json_object_iter)
c48088
+#define json_object_iter_at     (*_nm_jansson_json_object_iter_at)
c48088
+#define json_integer_value      (*_nm_jansson_json_integer_value)
c48088
+#define json_string_value       (*_nm_jansson_json_string_value)
c48088
+#endif
c48088
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
c48088
index 8d7bf08f9..ebbbfd3a4 100644
c48088
--- a/libnm-core/nm-utils.c
c48088
+++ b/libnm-core/nm-utils.c
c48088
@@ -36,7 +36,7 @@
c48088
 #include <linux/pkt_sched.h>
c48088
 
c48088
 #if WITH_JANSSON
c48088
-#include "nm-jansson.h"
c48088
+#include "nm-json.h"
c48088
 #include <jansson.h>
c48088
 #endif
c48088
 
c48088
-- 
c48088
2.14.3
c48088
c48088
c48088
From 0aa9273d334afec1d54878587b4f7fb9e2410f92 Mon Sep 17 00:00:00 2001
c48088
From: Thomas Haller <thaller@redhat.com>
c48088
Date: Tue, 9 Jan 2018 07:15:40 +0100
c48088
Subject: [PATCH 4/6] libnm: fix spelling for NM_JAONSSON_C define
c48088
c48088
(cherry picked from commit 288877848067c08abfd82d3ee72765f89ec79968)
c48088
---
c48088
 libnm-core/nm-json.c | 2 +-
c48088
 libnm-core/nm-json.h | 2 +-
c48088
 2 files changed, 2 insertions(+), 2 deletions(-)
c48088
c48088
diff --git a/libnm-core/nm-json.c b/libnm-core/nm-json.c
c48088
index 1f7d4398a..d58898ce2 100644
c48088
--- a/libnm-core/nm-json.c
c48088
+++ b/libnm-core/nm-json.c
c48088
@@ -21,7 +21,7 @@
c48088
 
c48088
 #include "nm-default.h"
c48088
 
c48088
-#define NM_JAONSSON_C
c48088
+#define NM_JANSSON_C
c48088
 #include "nm-json.h"
c48088
 
c48088
 void *_nm_jansson_json_object_iter_value;
c48088
diff --git a/libnm-core/nm-json.h b/libnm-core/nm-json.h
c48088
index e3718d93c..50b52e4f2 100644
c48088
--- a/libnm-core/nm-json.h
c48088
+++ b/libnm-core/nm-json.h
c48088
@@ -18,7 +18,7 @@
c48088
 
c48088
 gboolean nm_jansson_load (void);
c48088
 
c48088
-#ifndef NM_JAONSSON_C
c48088
+#ifndef NM_JANSSON_C
c48088
 #define json_object_iter_value  (*_nm_jansson_json_object_iter_value)
c48088
 #define json_object_key_to_iter (*_nm_jansson_json_object_key_to_iter)
c48088
 #define json_integer            (*_nm_jansson_json_integer)
c48088
-- 
c48088
2.14.3
c48088
c48088
c48088
From 5269978e379c3a03cb5b159beef747329a645446 Mon Sep 17 00:00:00 2001
c48088
From: Thomas Haller <thaller@redhat.com>
c48088
Date: Tue, 9 Jan 2018 07:17:06 +0100
c48088
Subject: [PATCH 5/6] libnm: add include guard to nm-json.h
c48088
c48088
(cherry picked from commit ee56c9250fc88eb1983bc587dc5052a70cb88e0f)
c48088
---
c48088
 libnm-core/nm-json.h | 4 ++++
c48088
 1 file changed, 4 insertions(+)
c48088
c48088
diff --git a/libnm-core/nm-json.h b/libnm-core/nm-json.h
c48088
index 50b52e4f2..513b8d369 100644
c48088
--- a/libnm-core/nm-json.h
c48088
+++ b/libnm-core/nm-json.h
c48088
@@ -15,6 +15,8 @@
c48088
  *
c48088
  * Copyright 2017, 2018 Red Hat, Inc.
c48088
  */
c48088
+#ifndef __NM_JSON_H__
c48088
+#define __NM_JSON_H__
c48088
 
c48088
 gboolean nm_jansson_load (void);
c48088
 
c48088
@@ -44,3 +46,5 @@ gboolean nm_jansson_load (void);
c48088
 #define json_integer_value      (*_nm_jansson_json_integer_value)
c48088
 #define json_string_value       (*_nm_jansson_json_string_value)
c48088
 #endif
c48088
+
c48088
+#endif /* __NM_JSON_H__ */
c48088
-- 
c48088
2.14.3
c48088
c48088
c48088
From ec630dc256b3e9cb80cd3ca9872c5a405ae21646 Mon Sep 17 00:00:00 2001
c48088
From: Thomas Haller <thaller@redhat.com>
c48088
Date: Tue, 9 Jan 2018 07:30:31 +0100
c48088
Subject: [PATCH 6/6] libnm: cleanup include in "libnm-core/nm-json.c"
c48088
c48088
We already define _GNU_SOURCE in "config.h", depending
c48088
on configure checks.
c48088
c48088
Also, we always should first include "config.h" (which means
c48088
to first include "nm-default.h").
c48088
c48088
Also, we don't need the entire <link.h>, <dlfcn.h> suffices.
c48088
c48088
(cherry picked from commit 84576ce86155e195985a1924c90782eb9e2e5beb)
c48088
---
c48088
 libnm-core/nm-json.c | 5 ++---
c48088
 1 file changed, 2 insertions(+), 3 deletions(-)
c48088
c48088
diff --git a/libnm-core/nm-json.c b/libnm-core/nm-json.c
c48088
index d58898ce2..f9042b1f3 100644
c48088
--- a/libnm-core/nm-json.c
c48088
+++ b/libnm-core/nm-json.c
c48088
@@ -16,14 +16,13 @@
c48088
  * Copyright 2017, 2018 Red Hat, Inc.
c48088
  */
c48088
 
c48088
-#define _GNU_SOURCE
c48088
-#include <link.h>
c48088
-
c48088
 #include "nm-default.h"
c48088
 
c48088
 #define NM_JANSSON_C
c48088
 #include "nm-json.h"
c48088
 
c48088
+#include <dlfcn.h>
c48088
+
c48088
 void *_nm_jansson_json_object_iter_value;
c48088
 void *_nm_jansson_json_object_key_to_iter;
c48088
 void *_nm_jansson_json_integer;
c48088
-- 
c48088
2.14.3
c48088