diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
commit | 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 (patch) | |
tree | 866986558761a9709a7af1940ba607128a45f775 /util/json.h | |
parent | Releasing debian version 2.1.2-2. (diff) | |
download | nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.tar.xz nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.zip |
Merging upstream version 2.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | util/json.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/util/json.h b/util/json.h index 2b8022a..1312cb8 100644 --- a/util/json.h +++ b/util/json.h @@ -3,6 +3,7 @@ #define __JSON__H #include <json.h> +#include "util/types.h" /* Wrappers around json-c's API */ @@ -14,17 +15,14 @@ json_object_object_add(o, k, json_object_new_int(v)) #define json_object_add_value_int(o, k, v) \ json_object_object_add(o, k, json_object_new_int(v)) -#ifdef CONFIG_JSONC_14 +#ifndef CONFIG_JSONC_14 +#define json_object_new_uint64(v) util_json_object_new_uint64(v) +#define json_object_get_uint64(v) util_json_object_get_uint64(v) +#endif #define json_object_add_value_uint64(o, k, v) \ json_object_object_add(o, k, json_object_new_uint64(v)) -#else -#define json_object_add_value_uint64(o, k, v) \ - if ((v) > UINT_MAX) { \ - fprintf(stderr, "Value overflow in %s", k); \ - json_object_object_add(o, k, json_object_new_int(-1)); \ - } else \ - json_object_object_add(o, k, json_object_new_int(v)) -#endif +#define json_object_add_value_uint128(o, k, v) \ + json_object_object_add(o, k, util_json_object_new_uint128(v)) #define json_object_add_value_double(o, k, v) \ json_object_object_add(o, k, util_json_object_new_double(v)) #define json_object_add_value_float(o, k, v) \ @@ -45,5 +43,9 @@ JSON_C_TO_STRING_NOSLASHESCAPE)) struct json_object *util_json_object_new_double(long double d); +struct json_object *util_json_object_new_uint64(uint64_t i); +struct json_object *util_json_object_new_uint128(nvme_uint128_t val); +struct json_object *util_json_object_new_uint128(nvme_uint128_t val); +uint64_t util_json_object_get_uint64(struct json_object *obj); #endif |