From 5046f0767250a4c61f0c0d49504e6dc4b40e1e1a Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 22 Jun 2017 00:19:24 +0000 Subject: lib: look at the correct token for json Signed-off-by: Quentin Young --- lib/json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/json.c') diff --git a/lib/json.c b/lib/json.c index 186efc9f48..5b7c3e9ffa 100644 --- a/lib/json.c +++ b/lib/json.c @@ -34,7 +34,7 @@ use_json (const int argc, struct cmd_token *argv[]) if (argc == 0) return 0; - if (argv[argc-1]->arg && strcmp(argv[argc-1]->arg, "json") == 0) + if (argv[argc-1]->arg && strmatch (argv[argc-1]->text, "json")) return 1; return 0; -- cgit v1.2.3 From d849012d19f1743691a05f4c38f69e6af5110806 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 29 Jun 2017 23:05:36 +0000 Subject: lib: always use 64-bit integers for json json-c does not (yet) offer support for unsigned integer types, and furthermore, the docs state that all integers are stored internally as 64-bit. So there's never a case in which we would want to limit, implicitly or otherwise, the range of an integer when adding it to a json object. Among other things this fixes the display of ASN values greater than (1/2) * (2^32 - 1) Signed-off-by: Quentin Young --- bgpd/bgpd.c | 2 +- lib/json.c | 8 +------- lib/json.h | 2 -- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'lib/json.c') diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index aed78cb35a..033a3d194d 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6405,7 +6405,7 @@ peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object { epoch_tbuf = time(NULL) - uptime1; json_object_string_add(json, "peerUptime", buf); - json_object_long_add(json, "peerUptimeMsec", uptime1 * 1000); + json_object_int_add(json, "peerUptimeMsec", uptime1 * 1000); json_object_int_add(json, "peerUptimeEstablishedEpoch", epoch_tbuf); } diff --git a/lib/json.c b/lib/json.c index 5b7c3e9ffa..d8c97e4486 100644 --- a/lib/json.c +++ b/lib/json.c @@ -48,13 +48,7 @@ json_object_string_add(struct json_object* obj, const char *key, } void -json_object_int_add(struct json_object* obj, const char *key, int32_t i) -{ - json_object_object_add(obj, key, json_object_new_int(i)); -} - -void -json_object_long_add(struct json_object* obj, const char *key, int64_t i) +json_object_int_add(struct json_object* obj, const char *key, int64_t i) { #if defined(HAVE_JSON_C_JSON_H) json_object_object_add(obj, key, json_object_new_int64(i)); diff --git a/lib/json.h b/lib/json.h index 5faaaa841a..86271703f4 100644 --- a/lib/json.h +++ b/lib/json.h @@ -43,8 +43,6 @@ extern int use_json(const int argc, struct cmd_token *argv[]); extern void json_object_string_add(struct json_object* obj, const char *key, const char *s); extern void json_object_int_add(struct json_object* obj, const char *key, - int32_t i); -extern void json_object_long_add(struct json_object* obj, const char *key, int64_t i); extern void json_object_boolean_false_add(struct json_object* obj, const char *key); -- cgit v1.2.3