static const char *reserved = "Reserved";
static const char *true_str = "True";
static const char *false_str = "False";
+static const char *result_str = "result";
+static const char *error_str = "error";
static void obj_add_uint_x(struct json_object *o, const char *k, __u32 v)
{
*(field + 32) & 0x4 ? "enabled" : "disabled");
break;
default:
- json_object_add_value_string(root, "error",
+ json_object_add_value_string(root, error_str,
"invalid directive operations for Identify Directives");
break;
}
result & 0xffff);
break;
default:
- json_object_add_value_string(root, "error",
+ json_object_add_value_string(root, error_str,
"invalid directive operations for Streams Directives");
break;
}
json_directive_show_fields_streams(doper, result, (__u16 *)field, root);
break;
default:
- json_object_add_value_string(root, "error", "invalid directive type");
+ json_object_add_value_string(root, error_str, "invalid directive type");
break;
}
}
sprintf(json_str, "%#x", nsid);
json_object_add_value_string(root, "nsid", json_str);
sprintf(json_str, "%#x", result);
- json_object_add_value_string(root, "result", json_str);
+ json_object_add_value_string(root, result_str, json_str);
if (json_print_ops.flags & VERBOSE) {
json_directive_show_fields(type, oper, result, buf, root);
int type;
if (status < 0) {
- json_object_add_value_string(root, "error", nvme_strerror(errno));
+ json_object_add_value_string(root, error_str, nvme_strerror(errno));
return json_output_object(root);
}
switch (type) {
case NVME_STATUS_TYPE_NVME:
- json_object_add_value_string(root, "error", nvme_status_to_string(val, false));
+ json_object_add_value_string(root, error_str, nvme_status_to_string(val, false));
json_object_add_value_string(root, "type", "nvme");
break;
case NVME_STATUS_TYPE_MI:
- json_object_add_value_string(root, "error", nvme_mi_status_to_string(val));
+ json_object_add_value_string(root, error_str, nvme_mi_status_to_string(val));
json_object_add_value_string(root, "type", "nvme-mi");
break;
default:
{
struct json_object *root = json_create_object();
char *value;
- const char *key = error ? "error" : "result";
+ const char *key = error ? error_str : result_str;
if (vasprintf(&value, msg, ap) < 0)
value = NULL;
error = NULL;
if (error)
- json_object_add_value_string(root, "error", error);
+ json_object_add_value_string(root, error_str, error);
else
- json_object_add_value_string(root, "error", "Could not allocate string");
+ json_object_add_value_string(root, error_str, "Could not allocate string");
json_output_object(root);