all: use nm-jansson.h

This commit is contained in:
Thomas Haller 2017-11-09 14:56:54 +01:00
parent 11b241eb1c
commit 650a47e16c
3 changed files with 4 additions and 37 deletions

View file

@ -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);
}

View file

@ -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 {

View file

@ -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"