summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-09 14:56:54 +0100
committerThomas Haller <thaller@redhat.com>2017-11-09 17:32:22 +0100
commit650a47e16c648d2e2c6e5528accf520f778db0dc (patch)
treedb1dc87114d00c360d073b39e89cdf3435421653
parent11b241eb1cbfe77c05fd3d5bbba8d4867b12c678 (diff)
downloadNetworkManager-650a47e16c648d2e2c6e5528accf520f778db0dc.tar.gz
all: use nm-jansson.h
-rw-r--r--libnm-core/nm-utils.c16
-rw-r--r--src/devices/ovs/nm-ovsdb.c23
-rw-r--r--src/devices/team/nm-device-team.c2
3 files changed, 4 insertions, 37 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index fadbcf342d..f2fa73248d 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -34,10 +34,7 @@
#include <sys/stat.h>
#include <net/if.h>
-#if WITH_JANSSON
-#include <jansson.h>
-#endif
-
+#include "nm-utils/nm-jansson.h"
#include "nm-utils/nm-enum-utils.h"
#include "nm-utils/nm-hash-utils.h"
#include "nm-common-macros.h"
@@ -4361,15 +4358,6 @@ nm_utils_is_json_object (const char *str, GError **error)
return TRUE;
}
-/* json_object_foreach_safe() is only available since Jansson 2.8,
- * reimplement it */
-#define _json_object_foreach_safe(object, n, key, value) \
- for (key = json_object_iter_key (json_object_iter (object)), \
- n = json_object_iter_next (object, json_object_iter_at (object, key)); \
- key && (value = json_object_iter_value (json_object_iter_at (object, key))); \
- key = json_object_iter_key (n), \
- n = json_object_iter_next (object, json_object_iter_at (object, key)))
-
gboolean
_nm_utils_team_config_equal (const char *conf1,
const char *conf2,
@@ -4433,7 +4421,7 @@ _nm_utils_team_config_equal (const char *conf1,
/* Only consider a given subset of nodes, others can change depending on
* current state */
for (i = 0, json = json1; i < 2; i++, json = json2) {
- _json_object_foreach_safe (json, tmp, key, value) {
+ json_object_foreach_safe (json, tmp, key, value) {
if (!NM_IN_STRSET (key, "runner", "link_watch"))
json_object_del (json, key);
}
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
index b44668c0d3..fbe9788256 100644
--- a/src/devices/ovs/nm-ovsdb.c
+++ b/src/devices/ovs/nm-ovsdb.c
@@ -22,35 +22,14 @@
#include "nm-ovsdb.h"
#include <string.h>
-#include <jansson.h>
#include <gmodule.h>
#include <gio/gunixsocketaddress.h>
+#include "nm-utils/nm-jansson.h"
#include "devices/nm-device.h"
#include "platform/nm-platform.h"
#include "nm-core-internal.h"
-/* Added in Jansson v2.4 (released Sep 23 2012), but travis.ci has v2.2. */
-#ifndef json_boolean
-#define json_boolean(val) ((val) ? json_true() : json_false())
-#endif
-
-/* Added in Jansson v2.5 (released Sep 19 2013), but travis.ci has v2.2. */
-#ifndef json_array_foreach
-#define json_array_foreach(array, index, value) \
- for (index = 0; \
- index < json_array_size(array) && (value = json_array_get(array, index)); \
- index++)
-#endif
-
-/* Added in Jansson v2.3 (released Jan 27 2012) */
-#ifndef json_object_foreach
-#define json_object_foreach(object, key, value) \
- for(key = json_object_iter_key(json_object_iter(object)); \
- key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
- key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
-#endif
-
/*****************************************************************************/
typedef struct {
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 098cd4372e..3f23a52005 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -28,8 +28,8 @@
#include <sys/wait.h>
#include <teamdctl.h>
#include <stdlib.h>
-#include <jansson.h>
+#include "nm-utils/nm-jansson.h"
#include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h"
#include "platform/nm-platform.h"