]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: always use 64-bit integers for json 769/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 29 Jun 2017 23:05:36 +0000 (23:05 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 29 Jun 2017 23:05:36 +0000 (23:05 +0000)
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 <qlyoung@cumulusnetworks.com>
bgpd/bgpd.c
lib/json.c
lib/json.h

index aed78cb35abe50456a30f7e7b2a8309a37c08eae..033a3d194d398265d052dea54b95206ff269ca6e 100644 (file)
@@ -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);
     }
 
index 5b7c3e9ffa8cc770be4d3478fcc0681a91e3e78b..d8c97e448667b8d664001d26077c32308a5afe0f 100644 (file)
@@ -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));
index 5faaaa841ab06186927bc563442ece5d08384c81..86271703f48017d070e93ec8bd8a03dce7a1b0e1 100644 (file)
@@ -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);