]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-json: add obj_add_uint_0nx() function
authorTokunori Ikegami <ikegami.t@gmail.com>
Tue, 30 Apr 2024 15:39:17 +0000 (00:39 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 3 May 2024 11:12:27 +0000 (13:12 +0200)
Supports field width to add "0x" prepended and zero padded hexadecimal.
obj_add_uint_02x() also changed to use the function as field width 2.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-print-json.c

index f0bea45499811ebeb3cf8f04519df967a50e944d..058b85656d5cd88a236a4c8006e7a31fa530ef99 100644 (file)
@@ -73,7 +73,7 @@ static void obj_add_uint_0x(struct json_object *o, const char *k, __u32 v)
        obj_add_str(o, k, str);
 }
 
-static void obj_add_uint_02x(struct json_object *o, const char *k, __u32 v)
+static void obj_add_uint_0nx(struct json_object *o, const char *k, __u32 v, int width)
 {
        char str[STR_LEN];
 
@@ -81,6 +81,11 @@ static void obj_add_uint_02x(struct json_object *o, const char *k, __u32 v)
        obj_add_str(o, k, str);
 }
 
+static void obj_add_uint_02x(struct json_object *o, const char *k, __u32 v)
+{
+       obj_add_uint_0nx(o, k, v, 2);
+}
+
 static void obj_add_uint_nx(struct json_object *o, const char *k, __u32 v)
 {
        char str[STR_LEN];