Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plugins/dapustor/dapustor-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct nvme_extended_additional_smart_log {
struct nvme_additional_smart_log_item inflight_write_io_cmd;
};

#ifdef CONFIG_JSONC
static void show_dapustor_add_smart_log_jsn(struct nvme_additional_smart_log *smart,
struct json_object *dev_stats)
{
Expand Down Expand Up @@ -348,6 +349,9 @@ static void show_dapustor_smart_log_jsn(struct nvme_additional_smart_log *smart,
json_print_object(root, NULL);
json_free_object(root);
}
#else /* CONFIG_JSONC */
#define show_dapustor_smart_log_jsn(smart, ext_smart, nsid, devname, has_ext)
#endif /* CONFIG_JSONC */

static void show_dapustor_add_smart_log(struct nvme_additional_smart_log *smart)
{
Expand Down Expand Up @@ -505,7 +509,9 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command *
const char *desc = "Get DapuStor vendor specific additional smart log, and show it.";
const char *namespace = "(optional) desired namespace";
const char *raw = "Dump output in binary format";
#ifdef CONFIG_JSONC
const char *json = "Dump output in json format";
#endif /* CONFIG_JSONC */

struct nvme_additional_smart_log smart_log;
struct nvme_extended_additional_smart_log ext_smart_log;
Expand All @@ -526,7 +532,9 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command *
OPT_ARGS(opts) = {
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
#ifdef CONFIG_JSONC
OPT_FLAG("json", 'j', &cfg.json, json),
#endif /* CONFIG_JSONC */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just thinking loud: if we introduce something like

#ifdef CONFIG_JSONC
#define OPT_FLAG_JSON OPT_FLAG("json",         'j', &cfg.json,       "Output In JSON format")
#else
#define OPT_FLAG_JSON 
#endif

on a global level we don't need these ugly ifdefs everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Fixed this by the PR #2637. Thank you.

OPT_END()
};

Expand Down
2 changes: 1 addition & 1 deletion plugins/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

if json_c_dep.found()
sources += [
'plugins/dapustor/dapustor-nvme.c',
'plugins/dell/dell-nvme.c',
'plugins/fdp/fdp.c',
'plugins/huawei/huawei-nvme.c',
Expand All @@ -23,6 +22,7 @@ endif

sources += [
'plugins/amzn/amzn-nvme.c',
'plugins/dapustor/dapustor-nvme.c',
'plugins/dera/dera-nvme.c',
'plugins/innogrit/innogrit-nvme.c',
'plugins/inspur/inspur-nvme.c',
Expand Down
Loading