Skip to content

Commit 936383f

Browse files
ikegami-tigaw
authored andcommitted
plugins: introduce OPT_FLAG_JSON for command option json
This is to not need ugly ifdefs everywhere. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent c4a1e11 commit 936383f

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

plugins/dapustor/dapustor-nvme.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,7 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command *
532532
OPT_ARGS(opts) = {
533533
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
534534
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
535-
#ifdef CONFIG_JSONC
536-
OPT_FLAG("json", 'j', &cfg.json, json),
537-
#endif /* CONFIG_JSONC */
535+
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
538536
OPT_END()
539537
};
540538

plugins/intel/intel-nvme.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
365365
OPT_ARGS(opts) = {
366366
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
367367
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
368-
#ifdef CONFIG_JSONC
369-
OPT_FLAG("json", 'j', &cfg.json, json),
370-
#endif /* CONFIG_JSONC */
368+
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
371369
OPT_END()
372370
};
373371

@@ -1069,9 +1067,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
10691067
OPT_ARGS(opts) = {
10701068
OPT_FLAG("write", 'w', &cfg.write, write),
10711069
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
1072-
#ifdef CONFIG_JSONC
1073-
OPT_FLAG("json", 'j', &cfg.json, json),
1074-
#endif /* CONFIG_JSONC */
1070+
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
10751071
OPT_END()
10761072
};
10771073

plugins/scaleflux/sfx-nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
344344
OPT_ARGS(opts) = {
345345
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
346346
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
347-
OPT_FLAG("json", 'j', &cfg.json, json),
347+
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
348348
OPT_END()
349349
};
350350

plugins/ssstc/ssstc-nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ int ssstc_get_add_smart_log(int argc, char **argv, struct command *cmd, struct p
402402
OPT_ARGS(opts) = {
403403
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
404404
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
405-
OPT_FLAG("json", 'j', &cfg.json, json),
405+
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
406406
OPT_END()
407407
};
408408

util/argconfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ enum argconfig_types {
9696
#define OPT_LIST(l, s, v, d, ...) OPT_STRING(l, s, "LIST", v, d, __VA_ARGS__)
9797
#define OPT_STR(l, s, v, d, ...) OPT_STRING(l, s, "STRING", v, d, __VA_ARGS__)
9898

99+
#ifdef CONFIG_JSONC
100+
#define OPT_FLAG_JSON(l, s, v, d, ...) OPT_FLAG(l, s, v, d, __VA_ARGS__)
101+
#else /* CONFIG_JSONC */
102+
#define OPT_FLAG_JSON(l, s, v, d, ...) OPT_END()
103+
#endif /* CONFIG_JSONC */
104+
99105
#define OPT_VALS(n) \
100106
struct argconfig_opt_val n[]
101107

0 commit comments

Comments
 (0)