Skip to content

Commit 7c22f11

Browse files
ikegami-tigaw
authored andcommitted
Revert "nvme-print-json: remove obj_print helper"
This reverts commit b854cbd. The helper function is used the json_r is set by json_show_init() then the function does not print but it is done by json_show_finish() instead. The get-feature command using nvme_show_init() and nvme_show_finish() those call json_show_init() and json_show_init() json print functions so the command json output does not work correctly currently. Also the init and finish functions will be used by the PR #2188 get-reg command also. (The issue found by the implementation working.) Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 90ee4ee commit 7c22f11

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

nvme-print-json.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ static void json_print(struct json_object *r)
179179
json_free_object(r);
180180
}
181181

182+
static void obj_print(struct json_object *o)
183+
{
184+
if (!json_r)
185+
json_print(o);
186+
}
187+
182188
static bool human(void)
183189
{
184190
return json_print_ops.flags & VERBOSE;
@@ -759,7 +765,7 @@ static void json_select_result(enum nvme_features_id fid, __u32 result)
759765
sprintf(json_str, "Feature: %#0*x: select", fid ? 4 : 2, fid);
760766
obj_add_array(r, json_str, feature);
761767

762-
json_print(r);
768+
obj_print(r);
763769
}
764770

765771
static void json_self_test_log(struct nvme_self_test_log *self_test, __u8 dst_entries,
@@ -3433,7 +3439,7 @@ static void json_feature_show(enum nvme_features_id fid, int sel, unsigned int r
34333439
sprintf(json_str, "%#0*x", result ? 10 : 8, result);
34343440
obj_add_str(r, nvme_select_to_string(sel), json_str);
34353441

3436-
json_print(r);
3442+
obj_print(r);
34373443
}
34383444

34393445
static void json_feature_show_fields(enum nvme_features_id fid, unsigned int result,
@@ -3556,7 +3562,7 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
35563562
break;
35573563
}
35583564

3559-
json_print(r);
3565+
obj_print(r);
35603566
}
35613567

35623568
void json_id_ctrl_rpmbs(__le32 ctrl_rpmbs)
@@ -3610,7 +3616,7 @@ void json_d(unsigned char *buf, int len, int width, int group)
36103616
d_json(buf, len, width, group, data);
36113617
obj_add_array(r, json_str, data);
36123618

3613-
json_print(r);
3619+
obj_print(r);
36143620
}
36153621

36163622
static void json_nvme_list_ctrl(struct nvme_ctrl_list *ctrl_list)
@@ -4311,7 +4317,7 @@ static void json_output_status(int status)
43114317

43124318
if (status < 0) {
43134319
obj_add_str(r, "error", nvme_strerror(errno));
4314-
json_print(r);
4320+
obj_print(r);
43154321
return;
43164322
}
43174323

@@ -4332,7 +4338,7 @@ static void json_output_status(int status)
43324338
break;
43334339
}
43344340

4335-
json_print(r);
4341+
obj_print(r);
43364342
}
43374343

43384344
static void json_output_error_status(int status, const char *msg, va_list ap)
@@ -4353,7 +4359,7 @@ static void json_output_error_status(int status, const char *msg, va_list ap)
43534359

43544360
if (status < 0) {
43554361
obj_add_str(r, "error", nvme_strerror(errno));
4356-
json_print(r);
4362+
obj_print(r);
43574363
return;
43584364
}
43594365

@@ -4376,7 +4382,7 @@ static void json_output_error_status(int status, const char *msg, va_list ap)
43764382

43774383
obj_add_int(r, "value", val);
43784384

4379-
json_print(r);
4385+
obj_print(r);
43804386
}
43814387

43824388
static void json_output_message(bool error, const char *msg, va_list ap)
@@ -4391,7 +4397,7 @@ static void json_output_message(bool error, const char *msg, va_list ap)
43914397

43924398
free(value);
43934399

4394-
json_print(r);
4400+
obj_print(r);
43954401
}
43964402

43974403
static void json_output_perror(const char *msg)

0 commit comments

Comments
 (0)