summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-09 17:04:07 +0100
committerThomas Haller <thaller@redhat.com>2017-11-09 17:34:39 +0100
commit595aaf0f3edcc2111207aa0321921e9217fc8b59 (patch)
tree1b2b7c7576beef33aad5b49de5a6b02fd760cb4c
parent650a47e16c648d2e2c6e5528accf520f778db0dc (diff)
downloadNetworkManager-595aaf0f3edcc2111207aa0321921e9217fc8b59.tar.gz
all: update compatiblity for older libjansson versionsth/jansson
- nm-ovsdb.c uses json_load_callback(), which is jansson v2.4. Hence, it cannot build the OVS plugin in our Travis-CI, which is still on Ubuntu Precise. Disable building the plugin in travis and add a compiler warning when building against an older version. - since jansson v2.3, there is json_object_key_to_iter() to implement the for-each macros. Use it in json_object_foreach_safe() when available.
-rw-r--r--.travis.yml2
-rw-r--r--shared/nm-utils/nm-jansson.h21
-rw-r--r--src/devices/ovs/nm-ovsdb.c4
3 files changed, 20 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml
index 0bcda1ded9..77b623bdab 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,7 +26,7 @@ addons:
coverity_scan:
project:
name: NetworkManager/NetworkManager
- build_command_prepend: sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no
+ build_command_prepend: sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --disable-ovs
build_command: make -j4
branch_pattern: .*coverity.*
diff --git a/shared/nm-utils/nm-jansson.h b/shared/nm-utils/nm-jansson.h
index a111837ddc..2b159e7872 100644
--- a/shared/nm-utils/nm-jansson.h
+++ b/shared/nm-utils/nm-jansson.h
@@ -30,8 +30,8 @@
#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))))
+ key && (value = json_object_iter_value(json_object_iter_at (object, key) )); \
+ key = json_object_iter_key(json_object_iter_next(object, json_object_iter_at (object, key))))
#endif
/* Added in Jansson v2.4 (released Sep 23 2012), but travis.ci has v2.2. */
@@ -42,19 +42,28 @@
/* 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++)
+ for(index = 0; \
+ index < json_array_size(array) && (value = json_array_get(array, index)); \
+ index++)
#endif
/* Added in Jansson v2.8 */
#ifndef json_object_foreach_safe
-#define json_object_foreach_safe(object, n, key, value) \
+#if JANSSON_VERSION_HEX < 0x020300
+#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)))
+#else
+#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_key_to_iter(key)); \
+ key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
+ key = json_object_iter_key(n), \
+ n = json_object_iter_next(object, json_object_key_to_iter(key)))
+#endif
#endif
#endif /* WITH_JANSON */
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
index fbe9788256..6d28bd2c55 100644
--- a/src/devices/ovs/nm-ovsdb.c
+++ b/src/devices/ovs/nm-ovsdb.c
@@ -32,6 +32,10 @@
/*****************************************************************************/
+#if JANSSON_VERSION_HEX < 0x020400
+#warning "requires at least libjansson 2.4"
+#endif
+
typedef struct {
char *name;
char *connection_uuid;