Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
nvme-cli.11415
0009-nvme-cli-Add-support-of-unsigned-long-long...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0009-nvme-cli-Add-support-of-unsigned-long-long-to-json-r.patch of Package nvme-cli.11415
From: Oleksii Timofieiev <tim.oleksii@gmail.com> Date: Sat, 20 Jan 2018 13:34:44 +0300 Subject: [PATCH] nvme-cli: Add support of unsigned long long to json routines Git-commit: 8c7b9b210cecc081d4ee340bec6d4666150d91f1 References: bsc#1099018 Signed-off-by: Oleksii Timofieiev <tim.oleksii@gmail.com> --- json.c | 20 ++++++++++++++++++++ json.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/json.c b/json.c index e127aa2..d2f9fb7 100644 --- a/json.c +++ b/json.c @@ -55,6 +55,19 @@ static struct json_value *json_create_value_int(long long number) return value; } +static struct json_value *json_create_value_uint(unsigned long long number) +{ + struct json_value *value = malloc(sizeof(struct json_value)); + + if (value) { + value->type = JSON_TYPE_UINT; + value->uint_number = number; + } else + fail_and_notify(); + + return value; +} + static struct json_value *json_create_value_float(long double number) { struct json_value *value = malloc(sizeof(struct json_value)); @@ -234,6 +247,8 @@ int json_object_add_value_type(struct json_object *obj, const char *name, int ty value = json_create_value_string(va_arg(args, char *)); else if (type == JSON_TYPE_INTEGER) value = json_create_value_int(va_arg(args, long long)); + else if (type == JSON_TYPE_UINT) + value = json_create_value_uint(va_arg(args, unsigned long long)); else if (type == JSON_TYPE_FLOAT) value = json_create_value_float(va_arg(args, long double)); else if (type == JSON_TYPE_OBJECT) @@ -270,6 +285,8 @@ int json_array_add_value_type(struct json_array *array, int type, ...) value = json_create_value_string(va_arg(args, char *)); else if (type == JSON_TYPE_INTEGER) value = json_create_value_int(va_arg(args, long long)); + else if (type == JSON_TYPE_UINT) + value = json_create_value_uint(va_arg(args, unsigned long long)); else if (type == JSON_TYPE_FLOAT) value = json_create_value_float(va_arg(args, double)); else if (type == JSON_TYPE_OBJECT) @@ -373,6 +390,9 @@ static void json_print_value(struct json_value *value, void *out) case JSON_TYPE_INTEGER: printf( "%lld", value->integer_number); break; + case JSON_TYPE_UINT: + printf( "%llu", value->uint_number); + break; case JSON_TYPE_FLOAT: printf( "%.0Lf", value->float_number); break; diff --git a/json.h b/json.h index f56723d..c4ea531 100644 --- a/json.h +++ b/json.h @@ -10,12 +10,14 @@ struct json_pair; #define JSON_TYPE_FLOAT 2 #define JSON_TYPE_OBJECT 3 #define JSON_TYPE_ARRAY 4 +#define JSON_TYPE_UINT 5 #define JSON_PARENT_TYPE_PAIR 0 #define JSON_PARENT_TYPE_ARRAY 1 struct json_value { int type; union { long long integer_number; + unsigned long long uint_number; long double float_number; char *string; struct json_object *object; @@ -54,6 +56,8 @@ void json_free_object(struct json_object *obj); int json_object_add_value_type(struct json_object *obj, const char *name, int type, ...); #define json_object_add_value_int(obj, name, val) \ json_object_add_value_type((obj), name, JSON_TYPE_INTEGER, (long long) (val)) +#define json_object_add_value_uint(obj, name, val) \ + json_object_add_value_type((obj), name, JSON_TYPE_UINT, (unsigned long long) (val)) #define json_object_add_value_float(obj, name, val) \ json_object_add_value_type((obj), name, JSON_TYPE_FLOAT, (val)) #define json_object_add_value_string(obj, name, val) \ @@ -65,6 +69,8 @@ int json_object_add_value_type(struct json_object *obj, const char *name, int ty int json_array_add_value_type(struct json_array *array, int type, ...); #define json_array_add_value_int(obj, val) \ json_array_add_value_type((obj), JSON_TYPE_INTEGER, (val)) +#define json_array_add_value_uint(obj, val) \ + json_array_add_value_type((obj), JSON_TYPE_UINT, (val)) #define json_array_add_value_float(obj, val) \ json_array_add_value_type((obj), JSON_TYPE_FLOAT, (val)) #define json_array_add_value_string(obj, val) \ -- 2.13.7
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor