From 2e2bfa31dc97159b7630c3c2913a49147be818d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Tue, 19 Jun 2018 18:25:34 +0200 Subject: [PATCH] Fix warnings due to json-c evolution MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The library json-c now returns size_t instead of int when querying length of arrays. Change-Id: Id52bb8e77da12cb01e61e1a7c7f4ae2fcbe4634e Signed-off-by: José Bollo --- bindings/intrinsics/afb-dbus-binding.c | 4 ++-- docs/{ => legacy}/afb-migration-v1-to-v2.md | 0 src/afb-monitor.c | 4 ++-- src/devtools/exprefs.c | 2 +- src/devtools/genskel.c | 10 +++++----- src/wrap-json.c | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) rename docs/{ => legacy}/afb-migration-v1-to-v2.md (100%) diff --git a/bindings/intrinsics/afb-dbus-binding.c b/bindings/intrinsics/afb-dbus-binding.c index 51474f6b..8f8a8866 100644 --- a/bindings/intrinsics/afb-dbus-binding.c +++ b/bindings/intrinsics/afb-dbus-binding.c @@ -366,7 +366,7 @@ static int packsingle(struct sd_bus_message *msg, const char *signature, struct goto error; if (json_object_is_type(item, json_type_array)) { /* Is an array! */ - count = json_object_array_length(item); + count = (int)json_object_array_length(item); index = 0; while(index < count) { rc = packsingle(msg, subsig, json_object_array_get_idx(item, index++)); @@ -461,7 +461,7 @@ static int packlist(struct sd_bus_message *msg, const char *signature, struct js } /* iterate over elements */ - count = json_object_array_length(list); + count = (int)json_object_array_length(list); index = 0; for (;;) { /* check state */ diff --git a/docs/afb-migration-v1-to-v2.md b/docs/legacy/afb-migration-v1-to-v2.md similarity index 100% rename from docs/afb-migration-v1-to-v2.md rename to docs/legacy/afb-migration-v1-to-v2.md diff --git a/src/afb-monitor.c b/src/afb-monitor.c index a50e2c65..68da8844 100644 --- a/src/afb-monitor.c +++ b/src/afb-monitor.c @@ -218,7 +218,7 @@ static struct json_object *get_verbosity(struct json_object *spec) json_object_iter_next(&it); } } else if (json_object_is_type(spec, json_type_array)) { - n = json_object_array_length(spec); + n = (int)json_object_array_length(spec); for (i = 0 ; i < n ; i++) get_verbosity_of(resu, json_object_get_string(json_object_array_get_idx(spec, i))); } else if (json_object_is_type(spec, json_type_string)) { @@ -280,7 +280,7 @@ static struct json_object *get_apis(struct json_object *spec) json_object_iter_next(&it); } } else if (json_object_is_type(spec, json_type_array)) { - n = json_object_array_length(spec); + n = (int)json_object_array_length(spec); for (i = 0 ; i < n ; i++) get_one_api(resu, json_object_get_string(json_object_array_get_idx(spec, i)), NULL); } else if (json_object_is_type(spec, json_type_string)) { diff --git a/src/devtools/exprefs.c b/src/devtools/exprefs.c index 9af40611..4cb13b73 100644 --- a/src/devtools/exprefs.c +++ b/src/devtools/exprefs.c @@ -136,7 +136,7 @@ struct json_object *expand(struct path path) case json_type_array: /* expand the values of arrays */ i = 0; - n = json_object_array_length(path.object); + n = (int)json_object_array_length(path.object); while (i != n) { o = json_object_array_get_idx(path.object, i); x = expand((struct path){ .object = o, .upper = &path }); diff --git a/src/devtools/genskel.c b/src/devtools/genskel.c index 55dd3c15..f5705a2e 100644 --- a/src/devtools/genskel.c +++ b/src/devtools/genskel.c @@ -153,7 +153,7 @@ struct json_object *expand_$ref(struct path path) case json_type_array: /* expand the values of arrays */ i = 0; - n = json_object_array_length(path.object); + n = (int)json_object_array_length(path.object); while (i != n) { o = json_object_array_get_idx(path.object, i); x = expand_$ref((struct path){ .object = o, .upper = &path }); @@ -290,7 +290,7 @@ void print_perms() int i, n; const char *fmtstr = cpp ? "\t%s" : "\t{ %s }"; - n = a_perms ? json_object_array_length(a_perms) : 0; + n = a_perms ? (int)json_object_array_length(a_perms) : 0; if (n) { printf("static const struct afb_auth _afb_auths_%s[] = {\n" , capi); i = 0; @@ -322,7 +322,7 @@ struct json_object *new_perm(struct json_object *obj, const char *desc) } /* creates the reference in the structure */ - asprintf(&b, "&_afb_auths_%s[%d]", capi, json_object_array_length(a_perms)); + asprintf(&b, "&_afb_auths_%s[%d]", capi, (int)json_object_array_length(a_perms)); x = json_object_new_string(desc); y = json_object_new_string(b); json_object_array_add(a_perms, x); @@ -352,7 +352,7 @@ struct json_object *decl_perm_a(enum optype op, struct json_object *obj) opstr = op==And ? "And" : "Or"; } x = NULL; - i = n = obj ? json_object_array_length(obj) : 0; + i = n = obj ? (int)json_object_array_length(obj) : 0; while (i) { y = decl_perm(json_object_array_get_idx(obj, --i)); if (!y) @@ -438,7 +438,7 @@ int get_session_a(int and, struct json_object *obj) { int i, n, x, y; - n = obj ? json_object_array_length(obj) : 0; + n = obj ? (int)json_object_array_length(obj) : 0; if (n == 0) return 0; diff --git a/src/wrap-json.c b/src/wrap-json.c index e757c369..6e604769 100644 --- a/src/wrap-json.c +++ b/src/wrap-json.c @@ -948,7 +948,7 @@ static struct json_object *clone_object(struct json_object *object, int subdepth */ static struct json_object *clone_array(struct json_object *array, int subdepth) { - int n = json_object_array_length(array); + int n = (int)json_object_array_length(array); struct json_object *r = json_object_new_array(); while (n) { n--; @@ -1183,8 +1183,8 @@ static int jcmp(struct json_object *x, struct json_object *y, int inc, int sort) break; case json_type_array: - nx = json_object_array_length(x); - ny = json_object_array_length(y); + nx = (int)json_object_array_length(x); + ny = (int)json_object_array_length(y); r = nx - ny; if (r > 0 && inc) r = 0; -- 2.16.6