diff --git a/.gitignore b/.gitignore index ffa123631e..7f78a8754e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,9 @@ tests/*.pyc .build .build-ci +.build-tools .cache +_codeql_detected_source_root # Ignore PyPI build artifacts dist/ diff --git a/fabrics.c b/fabrics.c index 9a1f0a0e98..82f01ba3a3 100644 --- a/fabrics.c +++ b/fabrics.c @@ -751,12 +751,9 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) struct config cfg = { 0 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("nqn", 'n', "NAME", &cfg.nqn, nvmf_nqn), - OPT_STRING("device", 'd', "DEV", &cfg.device, device), - OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"), - OPT_END() - }; + OPT_STRING("device", 'd', "DEV", &cfg.device, device)); ret = argconfig_parse(argc, argv, desc, opts); if (ret) @@ -839,11 +836,8 @@ int fabrics_disconnect_all(const char *desc, int argc, char **argv) struct config cfg = { 0 }; - OPT_ARGS(opts) = { - OPT_STRING("transport", 'r', "STR", (char *)&cfg.transport, nvmf_tport), - OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"), - OPT_END() - }; + NVME_ARGS(opts, + OPT_STRING("transport", 'r', "STR", (char *)&cfg.transport, nvmf_tport)); ret = argconfig_parse(argc, argv, desc, opts); if (ret) @@ -1018,13 +1012,10 @@ int fabrics_dim(const char *desc, int argc, char **argv) unsigned int verbose; } cfg = { 0 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("nqn", 'n', "NAME", &cfg.nqn, "Comma-separated list of DC nqn"), OPT_STRING("device", 'd', "DEV", &cfg.device, "Comma-separated list of DC nvme device handle."), - OPT_STRING("task", 't', "TASK", &cfg.tas, "[register|deregister]"), - OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"), - OPT_END() - }; + OPT_STRING("task", 't', "TASK", &cfg.tas, "[register|deregister]")); ret = argconfig_parse(argc, argv, desc, opts); if (ret) diff --git a/nvme-rpmb.c b/nvme-rpmb.c index 5e955846c7..42a67c6b4a 100644 --- a/nvme-rpmb.c +++ b/nvme-rpmb.c @@ -855,7 +855,7 @@ int rpmb_cmd_option(int argc, char **argv, struct command *acmd, struct plugin * .target = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("cmd", 'c', "command", &cfg.cmd, opt), OPT_STRING("msgfile", 'f', "FILE", &cfg.msgfile, mfile), OPT_STRING("keyfile", 'g', "FILE", &cfg.keyfile, kfile), @@ -863,9 +863,7 @@ int rpmb_cmd_option(int argc, char **argv, struct command *acmd, struct plugin * OPT_STRING("msg", 'd', "data", &cfg.msg, msg), OPT_UINT("address", 'o', &cfg.address, address), OPT_UINT("blocks", 'b', &cfg.blocks, blocks), - OPT_UINT("target", 't', &cfg.target, target), - OPT_END() - }; + OPT_UINT("target", 't', &cfg.target, target)); _cleanup_free_ unsigned char *key_buf = NULL; _cleanup_free_ unsigned char *msg_buf = NULL; diff --git a/plugins/amzn/amzn-nvme.c b/plugins/amzn/amzn-nvme.c index 014a3c3ad8..fdb48b2a71 100644 --- a/plugins/amzn/amzn-nvme.c +++ b/plugins/amzn/amzn-nvme.c @@ -485,11 +485,8 @@ static int get_stats(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, - "Output Format: normal|json"), - OPT_FLAG("details", 'd', &detail, "Detail IO histogram of each block size ranges"), - OPT_END()}; + NVME_ARGS(opts, + OPT_FLAG("details", 'd', &detail, "Detail IO histogram of each block size ranges")); rc = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (rc) diff --git a/plugins/dapustor/dapustor-nvme.c b/plugins/dapustor/dapustor-nvme.c index 268f45c101..f74d64a688 100644 --- a/plugins/dapustor/dapustor-nvme.c +++ b/plugins/dapustor/dapustor-nvme.c @@ -526,12 +526,10 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command * .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG_JSON("json", 'j', &cfg.json, json), - OPT_END() - }; + OPT_FLAG_JSON("json", 'j', &cfg.json, json)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/dera/dera-nvme.c b/plugins/dera/dera-nvme.c index 7a0d54ea8a..8db1847012 100644 --- a/plugins/dera/dera-nvme.c +++ b/plugins/dera/dera-nvme.c @@ -123,9 +123,7 @@ static int get_status(int argc, char **argv, struct command *acmd, struct plugin struct nvme_dera_smart_info_log log; int err; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/fdp/fdp.c b/plugins/fdp/fdp.c index 445a68ccce..56dfa103b0 100644 --- a/plugins/fdp/fdp.c +++ b/plugins/fdp/fdp.c @@ -45,13 +45,10 @@ static int fdp_configs(int argc, char **argv, struct command *acmd, .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("endgrp-id", 'e', &cfg.egid, egid), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable), - OPT_END() - }; + OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -120,12 +117,9 @@ static int fdp_usage(int argc, char **argv, struct command *acmd, struct plugin .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("endgrp-id", 'e', &cfg.egid, egid), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -186,12 +180,9 @@ static int fdp_stats(int argc, char **argv, struct command *acmd, struct plugin .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("endgrp-id", 'e', &cfg.egid, egid), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -249,13 +240,10 @@ static int fdp_events(int argc, char **argv, struct command *acmd, struct plugin .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("endgrp-id", 'e', &cfg.egid, egid), OPT_FLAG("host-events", 'E', &cfg.host_events, host_events), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -313,12 +301,9 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -388,11 +373,9 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin .pids = "", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id), - OPT_LIST("pids", 'p', &cfg.pids, _pids), - OPT_END() - }; + OPT_LIST("pids", 'p', &cfg.pids, _pids)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -459,14 +442,12 @@ static int fdp_set_events(int argc, char **argv, struct command *acmd, struct pl .sv = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid), OPT_SHRT("placement-handle", 'p', &cfg.ph, ph), OPT_FLAG("enable", 'e', &cfg.enable, enable), OPT_FLAG("save", 's', &cfg.sv, sv), - OPT_LIST("event-types", 't', &cfg.event_types, event_types), - OPT_END() - }; + OPT_LIST("event-types", 't', &cfg.event_types, event_types)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -537,13 +518,10 @@ static int fdp_feature(int argc, char **argv, struct command *acmd, struct plugi .endgid = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_SHRT("endgrp-id", 'e', &cfg.endgid, endurance_group), OPT_BYTE("enable-conf-idx", 'c', &cfg.fdpcidx, enable_conf_idx), - OPT_FLAG("disable", 'd', &cfg.disable, disable), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose), - OPT_END() - }; + OPT_FLAG("disable", 'd', &cfg.disable, disable)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c index 8ae01c49c1..4204ad3ed1 100644 --- a/plugins/huawei/huawei-nvme.c +++ b/plugins/huawei/huawei-nvme.c @@ -311,10 +311,7 @@ static int huawei_list(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); if (!ctx) return -ENOMEM; diff --git a/plugins/ibm/ibm-nvme.c b/plugins/ibm/ibm-nvme.c index d0c2107ce9..1846ed1058 100644 --- a/plugins/ibm/ibm-nvme.c +++ b/plugins/ibm/ibm-nvme.c @@ -236,10 +236,8 @@ static int get_ibm_addi_smart_log(int argc, char **argv, struct command *cmd, st .raw_binary = 0, }; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -368,10 +366,8 @@ static int get_ibm_vpd_log(int argc, char **argv, struct command *cmd, struct pl .raw_binary = 0, }; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err < 0) @@ -549,13 +545,10 @@ static int get_ibm_persistent_event_log(int argc, char **argv, .raw_binary = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("action", 'a', &cfg.action, action), OPT_UINT("log_len", 'l', &cfg.log_len, log_len), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 6b7fe4206a..957a2fc9d4 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -181,9 +181,7 @@ static int innogrit_geteventlog(int argc, char **argv, time_t timep; int ret = -1; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -228,9 +226,7 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *acmd, time_t timep; int ret = -1; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) diff --git a/plugins/inspur/inspur-nvme.c b/plugins/inspur/inspur-nvme.c index 041a0dede8..b4bf161e14 100644 --- a/plugins/inspur/inspur-nvme.c +++ b/plugins/inspur/inspur-nvme.c @@ -212,7 +212,7 @@ static int nvme_get_vendor_log(int argc, char **argv, struct command *acmd, stru __u8 local_mem[BYTE_OF_4K]; int err; - OPT_ARGS(opts) = { OPT_END() }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 545f44a615..9575f9c193 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -356,12 +356,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG_JSON("json", 'j', &cfg.json, json), - OPT_END() - }; + OPT_FLAG_JSON("json", 'j', &cfg.json, json)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -399,10 +397,8 @@ static int get_market_log(int argc, char **argv, struct command *acmd, struct pl struct config cfg = { }; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -461,10 +457,8 @@ static int get_temp_stats_log(int argc, char **argv, struct command *acmd, struc struct config cfg = { }; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1048,12 +1042,10 @@ static int get_lat_stats_log(int argc, char **argv, struct command *acmd, struct struct config cfg = { }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("write", 'w', &cfg.write, write), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG_JSON("json", 'j', &cfg.json, json), - OPT_END() - }; + OPT_FLAG_JSON("json", 'j', &cfg.json, json)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1367,15 +1359,13 @@ static int get_internal_log(int argc, char **argv, struct command *acmd, .core = -1 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("log", 'l', &cfg.log, log), OPT_INT("region", 'r', &cfg.core, core), OPT_INT("nlognum", 'm', &cfg.lnum, nlognum), OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_FILE("output-file", 'o', &cfg.file, file), - OPT_FLAG("verbose-nlog", 'v', &cfg.verbose, verbose), - OPT_END() - }; + OPT_FLAG("verbose-nlog", 'v', &cfg.verbose, verbose)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1633,12 +1623,10 @@ static int set_lat_stats_thresholds(int argc, char **argv, .bucket_thresholds = "", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("write", 'w', &cfg.write, write), OPT_LIST("bucket-thresholds", 't', &cfg.bucket_thresholds, - bucket_thresholds), - OPT_END() - }; + bucket_thresholds)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); diff --git a/plugins/lm/lm-nvme.c b/plugins/lm/lm-nvme.c index 6f65f6b3d8..a379a569bf 100644 --- a/plugins/lm/lm-nvme.c +++ b/plugins/lm/lm-nvme.c @@ -80,13 +80,11 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu .file = NULL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("size", 's', &cfg.sz, sz), OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid), OPT_BYTE("queue-type", 'q', &cfg.qt, qt), - OPT_FLAG("consent", 0, &cfg.consent, consent), - OPT_END() - }; + OPT_FLAG("consent", 0, &cfg.consent, consent)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -138,10 +136,8 @@ static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plu .cdqid = 0 }; - OPT_ARGS(opts) = { - OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid), - OPT_END() - }; + NVME_ARGS(opts, + OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -198,14 +194,12 @@ static int lm_track_send(int argc, char **argv, struct command *acmd, struct plu .stop = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_BYTE("mos", 'm', &cfg.mos, mos), OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid), OPT_FLAG("start", 0, &cfg.start, start), - OPT_FLAG("stop", 0, &cfg.stop, stop), - OPT_END() - }; + OPT_FLAG("stop", 0, &cfg.stop, stop)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -313,7 +307,7 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct .dudmq = false }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid), OPT_BYTE("stype", 't', &cfg.stype, stype), @@ -324,9 +318,7 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct OPT_BYTE("uidx", 'u', &cfg.uidx, uidx), OPT_LONG("offset", 'o', &cfg.offset, offset), OPT_UINT("numd", 'n', &cfg.numd, numd), - OPT_FILE("input-file", 'f', &cfg.input, input), - OPT_END() - }; + OPT_FILE("input-file", 'f', &cfg.input, input)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -448,7 +440,7 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct .human_readable = false }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid), OPT_BYTE("csuuidi", 'U', &cfg.csuuidi, csuuidi), @@ -457,10 +449,7 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct OPT_LONG("offset", 'o', &cfg.offset, offset), OPT_UINT("numd", 'n', &cfg.numd, numd), OPT_FILE("output-file", 'f', &cfg.output, output), - OPT_FMT("output-format", 0, &cfg.output_format, output_format), - OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_info), - OPT_END() - }; + OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_info)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -552,12 +541,10 @@ static int lm_set_cdq(int argc, char **argv, struct command *acmd, struct plugin .tpt = -1, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid), OPT_UINT("hp", 'H', &cfg.hp, hp), - OPT_UINT("tpt", 'T', &cfg.tpt, tpt), - OPT_END() - }; + OPT_UINT("tpt", 'T', &cfg.tpt, tpt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -597,11 +584,8 @@ static int lm_get_cdq(int argc, char **argv, struct command *acmd, struct plugin .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts, + OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index 57c6d5bd1d..ba6b45aa13 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -432,11 +432,9 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *ac .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -482,9 +480,7 @@ static int mb_get_powermanager_status(int argc, char **argv, struct command *acm _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int err; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -525,11 +521,9 @@ static int mb_set_powermanager_status(int argc, char **argv, struct command *acm .save = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("value", 'v', &cfg.value, value), - OPT_FLAG("save", 's', &cfg.save, save), - OPT_END() - }; + OPT_FLAG("save", 's', &cfg.save, save)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -578,10 +572,8 @@ static int mb_set_high_latency_log(int argc, char **argv, struct command *acmd, .value = 0, }; - OPT_ARGS(opts) = { - OPT_LIST("param", 'p', &cfg.param, param), - OPT_END() - }; + NVME_ARGS(opts, + OPT_LIST("param", 'p', &cfg.param, param)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -708,9 +700,7 @@ static int mb_high_latency_log_print(int argc, char **argv, struct command *acmd FILE *fdi = NULL; int err; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -780,11 +770,9 @@ static int mb_selective_download(int argc, char **argv, struct command *acmd, st .select = "\0", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("fw", 'f', "FILE", &cfg.fw, fw), - OPT_STRING("select", 's', "flag", &cfg.select, select), - OPT_END() - }; + OPT_STRING("select", 's', "flag", &cfg.select, select)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -984,10 +972,8 @@ static int mb_lat_stats_log_print(int argc, char **argv, struct command *acmd, s .write = 0, }; - OPT_ARGS(opts) = { - OPT_FLAG("write", 'w', &cfg.write, write), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("write", 'w', &cfg.write, write)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1027,9 +1013,7 @@ static int memblaze_clear_error_log(int argc, char **argv, struct command *acmd, .save = 0, }; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1563,9 +1547,8 @@ static int mb_get_smart_log_add(int argc, char **argv, struct command *acmd, str struct config cfg = {0}; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, "dump the whole log buffer in binary format"), - OPT_END()}; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, "dump the whole log buffer in binary format")); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -1710,7 +1693,7 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s struct config cfg = {0}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("sel-perf-log", 's', &cfg.perf_monitor, "Select features to turn on, default: Disable\n" " bit 0: latency statistics\n" @@ -1726,8 +1709,7 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s OPT_UINT("set-write-threshold", 'w', &cfg.write_threshold, "set write high latency log threshold, it's a 0-based value and unit is 10ms"), OPT_UINT("set-trim-threshold", 't', &cfg.de_allocate_trim_threshold, - "set trim high latency log threshold, it's a 0-based value and unit is 10ms"), - OPT_END()}; + "set trim high latency log threshold, it's a 0-based value and unit is 10ms")); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -1766,8 +1748,7 @@ static int mb_get_latency_feature(int argc, char **argv, struct command *acmd, s // Get the configuration - OPT_ARGS(opts) = { - OPT_END()}; + NVME_ARGS(opts); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -1914,12 +1895,11 @@ static int mb_get_latency_stats(int argc, char **argv, struct command *acmd, str struct config cfg = {0}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, - "dump the whole log buffer in binary format"), - OPT_END()}; + "dump the whole log buffer in binary format")); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -2020,12 +2000,11 @@ static int mb_get_high_latency_log(int argc, char **argv, struct command *acmd, struct config cfg = {0}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, - "dump the whole log buffer in binary format"), - OPT_END()}; + "dump the whole log buffer in binary format")); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; @@ -2263,7 +2242,7 @@ static int mb_get_performance_stats(int argc, char **argv, struct command *acmd, struct config cfg = {.duration = 1, .raw_binary = false}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("duration", 'd', &cfg.duration, @@ -2271,8 +2250,7 @@ static int mb_get_performance_stats(int argc, char **argv, struct command *acmd, OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, - "dump the whole log buffer in binary format"), - OPT_END()}; + "dump the whole log buffer in binary format")); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index 08d1e98257..cae2fc4c7a 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -592,11 +592,9 @@ static int micron_selective_download(int argc, char **argv, .select = "\0", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("fw", 'f', "FILE", &cfg.fw, fw), - OPT_STRING("select", 's', "flag", &cfg.select, select), - OPT_END() - }; + OPT_STRING("select", 's', "flag", &cfg.select, select)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -717,12 +715,10 @@ static int micron_smbus_option(int argc, char **argv, .status = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("option", 'o', "option", &opt.option, option), OPT_UINT("value", 'v', &opt.value, value), - OPT_UINT("save", 's', &opt.save, save), - OPT_END() - }; + OPT_UINT("save", 's', &opt.save, save)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -786,10 +782,8 @@ static int micron_temp_stats(int argc, char **argv, struct command *acmd, struct json_object *logPages; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -931,10 +925,8 @@ static int micron_pcie_stats(int argc, char **argv, __u32 correctable_errors; __u32 uncorrectable_errors; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1104,9 +1096,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, __u64 result = 0; __u8 fid = MICRON_FEATURE_CLEAR_PCI_CORRECTABLE_ERRORS; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -1818,10 +1808,8 @@ static int micron_nand_stats(int argc, char **argv, .fmt = "json", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1963,10 +1951,8 @@ static int micron_smart_ext_log(int argc, char **argv, struct format cfg = { .fmt = "json", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -2016,10 +2002,8 @@ static int micron_work_load_log(int argc, char **argv, struct command *acmd, str struct format cfg = { .fmt = "json", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -2068,10 +2052,8 @@ static int micron_vendor_telemetry_log(int argc, char **argv, struct format cfg = { .fmt = "json", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -2475,10 +2457,8 @@ static int micron_drive_info(int argc, char **argv, struct command *acmd, .fmt = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -2794,10 +2774,8 @@ static int micron_fw_activation_history(int argc, char **argv, struct command *a .fmt = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &eModel); if (err < 0) @@ -2902,12 +2880,10 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *acm .threshold = 0 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("option", 'o', "option", &opt.option, option), OPT_STRING("command", 'c', "command", &opt.command, cmdstr), - OPT_UINT("threshold", 't', &opt.threshold, thrtime), - OPT_END() - }; + OPT_UINT("threshold", 't', &opt.threshold, thrtime)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); @@ -3034,9 +3010,7 @@ static int micron_latency_stats_logs(int argc, char **argv, struct command *acmd int err = -1; const char *desc = "Display Latency tracking log information"; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err) @@ -3106,10 +3080,8 @@ static int micron_latency_stats_info(int argc, char **argv, struct command *acmd uint64_t *cmd_stats = &log.all_cmds[0]; char *cmd_str = "All"; - OPT_ARGS(opts) = { - OPT_STRING("command", 'c', "command", &opt.command, cmdstr), - OPT_END() - }; + NVME_ARGS(opts, + OPT_STRING("command", 'c', "command", &opt.command, cmdstr)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -3178,10 +3150,8 @@ static int micron_ocp_smart_health_logs(int argc, char **argv, struct command *a }; int err = 0; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &eModel); if (err < 0) @@ -3240,9 +3210,7 @@ static int micron_clr_fw_activation_history(int argc, char **argv, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); int err = 0; err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); @@ -3289,11 +3257,9 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, .select = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("option", 'o', "option", &opt.option, option), - OPT_UINT("select", 's', &opt.select, select), - OPT_END() - }; + OPT_UINT("select", 's', &opt.select, select)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -3683,12 +3649,10 @@ static int micron_internal_logs(int argc, char **argv, struct command *acmd, .log = 0x07, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("type", 't', "log type", &cfg.type, type), OPT_STRING("package", 'p', "FILE", &cfg.package, package), - OPT_UINT("data_area", 'd', &cfg.data_area, data_area), - OPT_END() - }; + OPT_UINT("data_area", 'd', &cfg.data_area, data_area)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -3968,9 +3932,7 @@ static int micron_logpage_dir(int argc, char **argv, struct command *acmd, _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int i; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &model); if (err < 0) @@ -4042,10 +4004,8 @@ static int micron_cloud_boot_SSD_version(int argc, char **argv, .fmt = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &eModel); if (err < 0) @@ -4106,10 +4066,8 @@ static int micron_device_waf(int argc, char **argv, struct command *acmd, .fmt = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &eModel); if (err < 0) @@ -4167,10 +4125,8 @@ static int micron_cloud_log(int argc, char **argv, struct command *acmd, .fmt = "json", }; - OPT_ARGS(opts) = { - OPT_FMT("format", 'f', &cfg.fmt, fmt), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FMT("format", 'f', &cfg.fmt, fmt)); err = micron_parse_options(&ctx, &hdl, argc, argv, desc, opts, &eModel); if (err < 0) diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c index 4f21689e91..ee183e023a 100644 --- a/plugins/nbft/nbft-plugin.c +++ b/plugins/nbft/nbft-plugin.c @@ -544,15 +544,12 @@ int show_nbft(int argc, char **argv, struct command *acmd, struct plugin *plugin int ret; unsigned int verbose = 0; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &format, "Output format: normal|json"), + NVME_ARGS(opts, OPT_FLAG("subsystem", 's', &show_subsys, "show NBFT subsystems"), OPT_FLAG("hfi", 'H', &show_hfi, "show NBFT HFIs"), OPT_FLAG("discovery", 'd', &show_discovery, "show NBFT discovery controllers"), OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), - OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), - OPT_END() - }; + OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity")); ret = argconfig_parse(argc, argv, desc, opts); if (ret) diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index 05ee21cd57..5e4d2c5fa4 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -910,11 +910,8 @@ static int netapp_smdevices(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FLAG("verbose", 'v', &cfg.verbose, "Increase output verbosity"), - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json|column"), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("verbose", 'v', &cfg.verbose, "Increase output verbosity")); if (!ctx) return -ENOMEM; @@ -1021,11 +1018,8 @@ static int netapp_ontapdevices(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FLAG("verbose", 'v', &cfg.verbose, "Increase output verbosity"), - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json|column"), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("verbose", 'v', &cfg.verbose, "Increase output verbosity")); if (!ctx) return -ENOMEM; diff --git a/plugins/ocp/ocp-clear-features.c b/plugins/ocp/ocp-clear-features.c index 2b5b8cb046..76cb35f3ad 100644 --- a/plugins/ocp/ocp-clear-features.c +++ b/plugins/ocp/ocp-clear-features.c @@ -22,11 +22,9 @@ static int ocp_clear_feature(int argc, char **argv, const char *desc, const __u8 bool uuid = true; int err; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("no-uuid", 'n', NULL, - "Skip UUID index search (UUID index not required for OCP 1.0)"), - OPT_END() - }; + "Skip UUID index search (UUID index not required for OCP 1.0)")); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -82,12 +80,10 @@ int get_ocp_error_counters(int argc, char **argv, struct command *acmd, .nsid = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid), - OPT_FLAG("no-uuid", 'u', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'u', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/ocp/ocp-fw-activation-history.c b/plugins/ocp/ocp-fw-activation-history.c index efe64528b9..0e0e4cc380 100644 --- a/plugins/ocp/ocp-fw-activation-history.c +++ b/plugins/ocp/ocp-fw-activation-history.c @@ -31,10 +31,7 @@ int ocp_fw_activation_history_log(int argc, char **argv, struct command *acmd, char *format = "normal"; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &format, "output format : normal | json"), - OPT_END() - }; + NVME_ARGS(opts); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index 288293d070..f1e8484ea7 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -275,11 +275,7 @@ static int ocp_latency_monitor_log(int argc, char **argv, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, - "output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -343,7 +339,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, .latency_monitor_feature_enable = 0x1, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("active_bucket_timer_threshold", 't', &cfg.active_bucket_timer_threshold, active_bucket_timer_threshold), OPT_UINT("active_threshold_a", 'a', &cfg.active_threshold_a, active_threshold_a), OPT_UINT("active_threshold_b", 'b', &cfg.active_threshold_b, active_threshold_b), @@ -353,9 +349,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, OPT_UINT("active_latency_minimum_window", 'w', &cfg.active_latency_minimum_window, active_latency_minimum_window), OPT_UINT("debug_log_trigger_enable", 'r', &cfg.debug_log_trigger_enable, debug_log_trigger_enable), OPT_UINT("discard_debug_log", 'l', &cfg.discard_debug_log, discard_debug_log), - OPT_UINT("latency_monitor_feature_enable", 'e', &cfg.latency_monitor_feature_enable, latency_monitor_feature_enable), - OPT_END() - }; + OPT_UINT("latency_monitor_feature_enable", 'e', &cfg.latency_monitor_feature_enable, latency_monitor_feature_enable)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -438,12 +432,10 @@ static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command .nsid = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid), - OPT_FLAG("no-uuid", 'u', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'u', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1456,15 +1448,12 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *acmd, struct const char *tele_log_suffix = "telemetry.bin"; bool host_behavior_changed = false; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STR("telemetry-log", 'l', &opt.telemetry_log, telemetry_log), OPT_STR("string-log", 's', &opt.string_log, string_log), OPT_FILE("output-file", 'f', &opt.output_file, output_file), - OPT_FMT("output-format", 'o', &opt.output_format, output_format), OPT_INT("data-area", 'a', &opt.data_area, data_area), - OPT_STR("telemetry-type", 't', &opt.telemetry_type, telemetry_type), - OPT_END() - }; + OPT_STR("telemetry-type", 't', &opt.telemetry_type, telemetry_type)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1708,10 +1697,7 @@ static int ocp_unsupported_requirements_log(int argc, char **argv, struct comman .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -1812,10 +1798,7 @@ static int ocp_error_recovery_log(int argc, char **argv, struct command *acmd, s .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json|binary"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -1915,10 +1898,7 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *ac .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json|binary"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -1982,10 +1962,8 @@ static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct comma .tps = 0, }; - OPT_ARGS(opts) = { - OPT_BYTE("telemetry-profile-select", 't', &cfg.tps, tps), - OPT_END() - }; + NVME_ARGS(opts, + OPT_BYTE("telemetry-profile-select", 't', &cfg.tps, tps)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2029,12 +2007,10 @@ static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct comma .nsid = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid), - OPT_FLAG("no-uuid", 'u', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'u', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2128,12 +2104,10 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *a .save = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("power-state", 'p', &cfg.power_state, power_state), OPT_FLAG("save", 's', &cfg.save, save), - OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'n', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2204,12 +2178,10 @@ static int get_dssd_power_state_feature(int argc, char **argv, struct command *a .all = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 'S', &cfg.sel, sel), OPT_FLAG("all", 'a', NULL, all), - OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'n', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2261,12 +2233,10 @@ static int set_plp_health_check_interval(int argc, char **argv, struct command * .sv = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("plp_health_interval", 'p', &cfg.plp_health_interval, plp_health_interval), OPT_FLAG("save", 's', &cfg.sv, sv), - OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'n', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2318,10 +2288,8 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command * .sel = 0, }; - OPT_ARGS(opts) = { - OPT_BYTE("sel", 'S', &cfg.sel, sel), - OPT_END() - }; + NVME_ARGS(opts, + OPT_BYTE("sel", 'S', &cfg.sel, sel)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2372,11 +2340,9 @@ static int set_dssd_async_event_config(int argc, char **argv, struct command *ac .sv = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("enable-panic-notices", 'e', &cfg.epn, epn), - OPT_FLAG("save", 's', &cfg.sv, sv), - OPT_END() - }; + OPT_FLAG("save", 's', &cfg.sv, sv)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2425,10 +2391,8 @@ static int get_dssd_async_event_config(int argc, char **argv, struct command *ac .sel = 0, }; - OPT_ARGS(opts) = { - OPT_BYTE("sel", 'S', &cfg.sel, sel), - OPT_END() - }; + NVME_ARGS(opts, + OPT_BYTE("sel", 'S', &cfg.sel, sel)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2505,12 +2469,8 @@ static int ocp_telemetry_str_log_format(int argc, char **argv, struct command *a .output_file = NULL, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, - "output Format:normal|json|binary"), - OPT_FILE("output-file", 'f', &cfg.output_file, output_file), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FILE("output-file", 'f', &cfg.output_file, output_file)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -2619,10 +2579,7 @@ static int ocp_tcg_configuration_log(int argc, char **argv, struct command *acmd .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -2734,12 +2691,10 @@ static int get_error_injection(int argc, char **argv, struct command *acmd, stru struct config cfg = { 0 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_FLAG("all-ns", 'a', NULL, all_ns), - OPT_END() - }; + OPT_FLAG("all-ns", 'a', NULL, all_ns)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2897,11 +2852,9 @@ static int get_enable_ieee1667_silo(int argc, char **argv, struct command *acmd, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("sel", 's', &cfg.sel, sel), - OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'n', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -2957,12 +2910,10 @@ static int set_enable_ieee1667_silo(int argc, char **argv, struct command *acmd, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("enable", 'e', NULL, no_uuid), OPT_FLAG("save", 's', NULL, save), - OPT_FLAG("no-uuid", 'n', NULL, no_uuid), - OPT_END() - }; + OPT_FLAG("no-uuid", 'n', NULL, no_uuid)); err = parse_and_open(&ctx, &hdl, argc, argv, enable_ieee1667_silo, opts); if (err) diff --git a/plugins/ocp/ocp-smart-extended-log.c b/plugins/ocp/ocp-smart-extended-log.c index 3eef14a9a7..bb8c153f9b 100644 --- a/plugins/ocp/ocp-smart-extended-log.c +++ b/plugins/ocp/ocp-smart-extended-log.c @@ -113,11 +113,8 @@ int ocp_smart_add_log(int argc, char **argv, struct command *acmd, .output_format_version = 1, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"), - OPT_UINT("output-format-version", 0, &cfg.output_format_version, "output Format version: 1|2"), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("output-format-version", 0, &cfg.output_format_version, "output Format version: 1|2")); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) diff --git a/plugins/sandisk/sandisk-nvme.c b/plugins/sandisk/sandisk-nvme.c index aa73b25771..0b1096f4e9 100644 --- a/plugins/sandisk/sandisk-nvme.c +++ b/plugins/sandisk/sandisk-nvme.c @@ -353,16 +353,14 @@ static int sndk_vs_internal_fw_log(int argc, char **argv, .verbose = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("output-file", 'o', &cfg.file, file), OPT_UINT("transfer-size", 's', &cfg.xfer_size, size), OPT_UINT("data-area", 'd', &cfg.data_area, data_area), OPT_LONG("file-size", 'f', &cfg.file_size, file_size), OPT_LONG("offset", 'e', &cfg.offset, offset), OPT_FILE("type", 't', &cfg.type, type), - OPT_FLAG("verbose", 'v', &cfg.verbose, verbose), - OPT_END() - }; + OPT_FLAG("verbose", 'v', &cfg.verbose, verbose)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -569,10 +567,8 @@ static int sndk_drive_resize(int argc, char **argv, .size = 0, }; - OPT_ARGS(opts) = { - OPT_UINT("size", 's', &cfg.size, size), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("size", 's', &cfg.size, size)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -920,10 +916,7 @@ static int sndk_vs_fw_activate_history(int argc, char **argv, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -971,9 +964,7 @@ static int sndk_clear_fw_activate_history(int argc, char **argv, __u64 capabilities = 0; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -1043,9 +1034,7 @@ static int sndk_capabilities(int argc, char **argv, uint64_t capabilities = 0; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 23783a5c60..10695593e4 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -347,12 +347,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG_JSON("json", 'j', &cfg.json, json), - OPT_END() - }; + OPT_FLAG_JSON("json", 'j', &cfg.json, json)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -513,11 +511,9 @@ static int get_lat_stats_log(int argc, char **argv, struct command *acmd, struct struct config cfg = { }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("write", 'w', &cfg.write, write), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -654,9 +650,7 @@ static int sfx_get_bad_block(int argc, char **argv, struct command *acmd, struct char *desc = "Get bad block table of sfx block device."; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -710,10 +704,8 @@ static int query_cap_info(int argc, char **argv, struct command *acmd, struct pl struct config cfg; int err = 0; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -840,12 +832,10 @@ static int change_cap(int argc, char **argv, struct command *acmd, struct plugin .force = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("cap", 'c', &cfg.capacity_in_gb, cap_gb), OPT_SUFFIX("cap-byte", 'z', &cfg.cap_in_byte, cap_byte), - OPT_FLAG("force", 'f', &cfg.force, force), - OPT_END() - }; + OPT_FLAG("force", 'f', &cfg.force, force)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -952,13 +942,11 @@ static int sfx_set_feature(int argc, char **argv, struct command *acmd, struct p .force = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id), OPT_UINT("value", 'v', &cfg.value, value), - OPT_FLAG("force", 's', &cfg.force, force), - OPT_END() - }; + OPT_FLAG("force", 's', &cfg.force, force)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1046,11 +1034,9 @@ static int sfx_get_feature(int argc, char **argv, struct command *acmd, struct p .feature_id = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id), - OPT_END() - }; + OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1379,14 +1365,12 @@ static int sfx_dump_evtlog(int argc, char **argv, struct command *acmd, struct p .output = NULL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("file", 'f', &cfg.file, file), OPT_UINT("namespace_id", 'n', &cfg.namespace_id, namespace_id), OPT_UINT("storage_medium", 's', &cfg.storage_medium, storage_medium), OPT_FLAG("parse", 'p', &cfg.parse, parse), - OPT_FILE("output", 'o', &cfg.output, output), - OPT_END() - }; + OPT_FILE("output", 'o', &cfg.output, output)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1502,14 +1486,12 @@ static int sfx_expand_cap(int argc, char **argv, struct command *acmd, struct pl .units = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace_id", 'n', &cfg.namespace_id, namespace_id), OPT_LONG("namespace_size", 's', &cfg.namespace_size, namespace_size), OPT_LONG("namespace_cap", 'c', &cfg.namespace_cap, namespace_cap), OPT_UINT("lbaf", 'l', &cfg.lbaf, lbaf), - OPT_UINT("units", 'u', &cfg.units, units), - OPT_END() - }; + OPT_UINT("units", 'u', &cfg.units, units)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1572,10 +1554,8 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin .json = false }; - OPT_ARGS(opts) = { - OPT_FLAG("json-print", 'j', &cfg.json, json_desc), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("json-print", 'j', &cfg.json, json_desc)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index 44956c5d09..a0da0ac4ad 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -163,10 +163,7 @@ static int log_pages_supp(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -909,10 +906,7 @@ static int vs_smart_log(int argc, char **argv, struct command *acmd, struct plug .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1091,10 +1085,7 @@ static int temp_stats(int argc, char **argv, struct command *acmd, struct plugin .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1265,10 +1256,7 @@ static int vs_pcie_error_log(int argc, char **argv, struct command *acmd, struct .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1411,10 +1399,7 @@ static int stx_vs_fw_activate_history(int argc, char **argv, struct command *acm .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err < 0) { @@ -1465,10 +1450,8 @@ static int clear_fw_activate_history(int argc, char **argv, struct command *acmd .save = 0, }; - OPT_ARGS(opts) = { - OPT_FLAG("save", 's', &cfg.save, save), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("save", 's', &cfg.save, save)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err < 0) { @@ -1525,10 +1508,8 @@ static int vs_clr_pcie_correctable_errs(int argc, char **argv, struct command *a .save = 0, }; - OPT_ARGS(opts) = { - OPT_FLAG("save", 's', &cfg.save, save), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("save", 's', &cfg.save, save)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -1593,12 +1574,10 @@ static int get_host_tele(int argc, char **argv, struct command *acmd, struct plu .log_id = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_UINT("log_specific", 'i', &cfg.log_id, log_specific), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1703,11 +1682,9 @@ static int get_ctrl_tele(int argc, char **argv, struct command *acmd, struct plu .namespace_id = 0xffffffff, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1821,11 +1798,9 @@ static int vs_internal_log(int argc, char **argv, struct command *acmd, struct p .file = "", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_FILE("dump-file", 'f', &cfg.file, file), - OPT_END() - }; + OPT_FILE("dump-file", 'f', &cfg.file, file)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 3c43602778..8882b4ce72 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -132,11 +132,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -201,16 +199,14 @@ static int get_additional_feature(int argc, char **argv, struct command *acmd, s .data_len = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id), OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_UINT("data-len", 'l', &cfg.data_len, data_len), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11), - OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable), - OPT_END() - }; + OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -282,15 +278,13 @@ static int set_additional_feature(int argc, char **argv, struct command *acmd, s .save = 0, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id), OPT_UINT("value", 'v', &cfg.value, value), OPT_UINT("data-len", 'l', &cfg.data_len, data_len), OPT_FILE("data", 'd', &cfg.file, data), - OPT_FLAG("save", 's', &cfg.save, save), - OPT_END() - }; + OPT_FLAG("save", 's', &cfg.save, save)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 3146823175..638713154f 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -83,10 +83,7 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *a .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-get-drive-info.c b/plugins/solidigm/solidigm-get-drive-info.c index 9e044b987a..3f2e3ed37a 100644 --- a/plugins/solidigm/solidigm-get-drive-info.c +++ b/plugins/solidigm/solidigm-get-drive-info.c @@ -25,10 +25,7 @@ int sldgm_get_drive_info(int argc, char **argv, struct command *acmd, struct plu __u16 ftl_unit_size; int err; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &output_format, "normal|json"), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-internal-logs.c b/plugins/solidigm/solidigm-internal-logs.c index 49700353ab..837e386b0f 100644 --- a/plugins/solidigm/solidigm-internal-logs.c +++ b/plugins/solidigm/solidigm-internal-logs.c @@ -853,12 +853,10 @@ int solidigm_get_internal_log(int argc, char **argv, struct command *acmd, .type = type_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_STRING("type", 't', "ALL|CIT|HIT|NLOG|ASSERT|EVENT|EXTENDED", &cfg.type, type), OPT_STRING("dir-name", 'd', "DIRECTORY", &cfg.out_dir, out_dir), - OPT_FLAG("verbose", 'v', &cfg.verbose, verbose), - OPT_END() - }; + OPT_FLAG("verbose", 'v', &cfg.verbose, verbose)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-latency-tracking.c b/plugins/solidigm/solidigm-latency-tracking.c index f6142ea9e1..8078fc4b0a 100644 --- a/plugins/solidigm/solidigm-latency-tracking.c +++ b/plugins/solidigm/solidigm-latency-tracking.c @@ -363,15 +363,12 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *acm .has_average_latency_field = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("enable", 'e', <.cfg.enable, "Enable Latency Tracking"), OPT_FLAG("disable", 'd', <.cfg.disable, "Disable Latency Tracking"), OPT_FLAG("read", 'r', <.cfg.read, "Get read statistics"), OPT_FLAG("write", 'w', <.cfg.write, "Get write statistics"), - OPT_BYTE("type", 't', <.cfg.type, "Log type to get"), - OPT_FMT("output-format", 'o', <.cfg.output_format, output_format), - OPT_END() - }; + OPT_BYTE("type", 't', <.cfg.type, "Log type to get")); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-log-page-dir.c b/plugins/solidigm/solidigm-log-page-dir.c index bffd7361fb..84ec6cf038 100644 --- a/plugins/solidigm/solidigm-log-page-dir.c +++ b/plugins/solidigm/solidigm-log-page-dir.c @@ -184,12 +184,7 @@ int solidigm_get_log_page_directory_log(int argc, char **argv, struct command *a const int NO_UUID_INDEX = 0; const char *description = "Retrieves list of supported log pages for each UUID index."; - OPT_ARGS(options) = { - OPT_FMT("output-format", 'o', &nvme_cfg.output_format, - "output format : normal | json"), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose), - OPT_END() - }; + NVME_ARGS(options); _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; diff --git a/plugins/solidigm/solidigm-market-log.c b/plugins/solidigm/solidigm-market-log.c index 37173cf4b9..cd6efdeef9 100644 --- a/plugins/solidigm/solidigm-market-log.c +++ b/plugins/solidigm/solidigm-market-log.c @@ -36,11 +36,8 @@ int sldgm_get_market_log(int argc, char **argv, struct command *acmd, __u8 uuid_idx; bool raw_binary = false; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &raw_binary, raw), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-ocp-version.c b/plugins/solidigm/solidigm-ocp-version.c index 5904f87c6b..ccd1a391e8 100644 --- a/plugins/solidigm/solidigm-ocp-version.c +++ b/plugins/solidigm/solidigm-ocp-version.c @@ -12,9 +12,7 @@ int sldgm_ocp_version(int argc, char **argv, struct command *acmd, struct plugin { const char *desc = "Prints OCP extensions version of Solidigm plugin"; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); int err = argconfig_parse(argc, argv, desc, opts); diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index ae12d0cb89..4660218eb7 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -249,12 +249,8 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *acm .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, "(optional) desired namespace"), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, "(optional) desired namespace")); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-telemetry.c b/plugins/solidigm/solidigm-telemetry.c index 53b468043b..ee8f430816 100644 --- a/plugins/solidigm/solidigm-telemetry.c +++ b/plugins/solidigm/solidigm-telemetry.c @@ -89,16 +89,13 @@ int solidigm_get_telemetry_log(int argc, char **argv, struct command *acmd, stru .ctrl_init = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("host-generate", 'g', &cfg.host_gen, hgen), OPT_FLAG("controller-init", 'c', &cfg.ctrl_init, cgen), OPT_BYTE("data-area", 'd', &cfg.data_area, dgen), OPT_FILE("config-file", 'j', &cfg.cfg_file, cfile), OPT_FILE("source-file", 's', &cfg.binary_file, sfile), - OPT_STR("jq-filter", 'q', &cfg.jq_filter, jqfilt), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose), - OPT_END() - }; + OPT_STR("jq-filter", 'q', &cfg.jq_filter, jqfilt)); int err = argconfig_parse(argc, argv, desc, opts); diff --git a/plugins/solidigm/solidigm-temp-stats.c b/plugins/solidigm/solidigm-temp-stats.c index dd22af2eaf..8ea758b1ce 100644 --- a/plugins/solidigm/solidigm-temp-stats.c +++ b/plugins/solidigm/solidigm-temp-stats.c @@ -57,10 +57,8 @@ int sldgm_get_temp_stats_log(int argc, char **argv, struct command *acmd, struct .raw_binary = false, }; - OPT_ARGS(opts) = { - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/solidigm/solidigm-workload-tracker.c b/plugins/solidigm/solidigm-workload-tracker.c index 6f16b06974..a9cb859de1 100644 --- a/plugins/solidigm/solidigm-workload-tracker.c +++ b/plugins/solidigm/solidigm-workload-tracker.c @@ -525,7 +525,7 @@ int sldgm_get_workload_tracker(int argc, char **argv, struct command *acmd, stru join_options(type_options, trk_types, ARRAY_SIZE(trk_types)); join_options(sample_options, samplet, ARRAY_SIZE(samplet)); - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_BYTE("uuid-index", 'U', &wlt.uuid_index, "specify uuid index"), OPT_FLAG("enable", 'e', &cfg.enable, "tracker enable"), OPT_FLAG("disable", 'd', &cfg.disable, "tracker disable"), @@ -541,10 +541,7 @@ int sldgm_get_workload_tracker(int argc, char **argv, struct command *acmd, stru OPT_FLAG("trigger-on-delta", 'D', &cfg.trigger_on_delta, "Trigger on delta to stop sampling"), OPT_FLAG("trigger-on-latency", 'L', &cfg.trigger_on_latency, - "Use latency tracker to trigger stop sampling"), - OPT_INCR("verbose", 'v', &nvme_cfg.verbose, "Increase logging verbosity"), - OPT_END() - }; + "Use latency tracker to trigger stop sampling")); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/ssstc/ssstc-nvme.c b/plugins/ssstc/ssstc-nvme.c index 90571f7b1f..0a2468b9d6 100644 --- a/plugins/ssstc/ssstc-nvme.c +++ b/plugins/ssstc/ssstc-nvme.c @@ -402,12 +402,10 @@ int ssstc_get_add_smart_log(int argc, char **argv, struct command *acmd, struct .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_FLAG_JSON("json", 'j', &cfg.json, json), - OPT_END() - }; + OPT_FLAG_JSON("json", 'j', &cfg.json, json)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index d4b783bbb8..2b0fd926aa 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -436,12 +436,10 @@ static int vendor_log(int argc, char **argv, struct command *acmd, struct plugin .log = 0xca }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), OPT_FILE("output-file", 'o', &cfg.output_file, output_file), - OPT_UINT("log", 'l', &cfg.log, log), - OPT_END() - }; + OPT_UINT("log", 'l', &cfg.log, log)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -485,11 +483,9 @@ static int internal_log(int argc, char **argv, struct command *acmd, struct plug .prev_log = false }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("output-file", 'o', &cfg.output_file, output_file), - OPT_FLAG("prev-log", 'p', &cfg.prev_log, prev_log), - OPT_END() - }; + OPT_FLAG("prev-log", 'p', &cfg.prev_log, prev_log)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { @@ -526,9 +522,7 @@ static int clear_correctable_errors(int argc, char **argv, struct command *acmd, __u64 result; int err; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c index bd088ed526..e62115fc27 100644 --- a/plugins/transcend/transcend-nvme.c +++ b/plugins/transcend/transcend-nvme.c @@ -26,9 +26,7 @@ static int getHealthValue(int argc, char **argv, struct command *acmd, struct pl _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int result; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); result = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (result) { @@ -61,9 +59,7 @@ static int getBadblock(int argc, char **argv, struct command *acmd, struct plugi unsigned char data[1] = {0}; int result; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); result = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (result) { diff --git a/plugins/virtium/virtium-nvme.c b/plugins/virtium/virtium-nvme.c index 88ec40db2c..f3fc93251c 100644 --- a/plugins/virtium/virtium-nvme.c +++ b/plugins/virtium/virtium-nvme.c @@ -957,13 +957,11 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, .test_name = NULL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_DOUBLE("run-time", 'r', &cfg.run_time_hrs, run_time), OPT_DOUBLE("freq", 'f', &cfg.log_record_frequency_hrs, freq), OPT_FILE("output-file", 'o', &cfg.output_file, output_file), - OPT_STRING("test-name", 'n', "NAME", &cfg.test_name, test_name), - OPT_END() - }; + OPT_STRING("test-name", 'n', "NAME", &cfg.test_name, test_name)); vt_generate_vtview_log_file_name(vt_default_log_file_name); @@ -1031,9 +1029,7 @@ static int vt_show_identify(int argc, char **argv, struct command *acmd, struct struct nvme_id_ctrl ctrl; int ret, err = 0; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) { diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index bd4510e1c0..da46e0755d 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -3912,11 +3912,9 @@ static int wdc_cap_diag(int argc, char **argv, struct command *acmd, .xfer_size = 0x10000 }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("output-file", 'o', &cfg.file, file), - OPT_UINT("transfer-size", 's', &cfg.xfer_size, size), - OPT_END() - }; + OPT_UINT("transfer-size", 's', &cfg.xfer_size, size)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4342,16 +4340,14 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, .verbose = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("output-file", 'o', &cfg.file, file), OPT_UINT("transfer-size", 's', &cfg.xfer_size, size), OPT_UINT("data-area", 'd', &cfg.data_area, data_area), OPT_LONG("file-size", 'f', &cfg.file_size, file_size), OPT_LONG("offset", 'e', &cfg.offset, offset), OPT_FILE("type", 't', &cfg.type, type), - OPT_FLAG("verbose", 'v', &cfg.verbose, verbose), - OPT_END() - }; + OPT_FLAG("verbose", 'v', &cfg.verbose, verbose)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4719,10 +4715,8 @@ static int wdc_drive_log(int argc, char **argv, struct command *acmd, .file = NULL }; - OPT_ARGS(opts) = { - OPT_FILE("output-file", 'o', &cfg.file, file), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FILE("output-file", 'o', &cfg.file, file)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4767,10 +4761,8 @@ static int wdc_get_crash_dump(int argc, char **argv, struct command *acmd, .file = NULL, }; - OPT_ARGS(opts) = { - OPT_FILE("output-file", 'o', &cfg.file, file), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FILE("output-file", 'o', &cfg.file, file)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4810,10 +4802,8 @@ static int wdc_get_pfail_dump(int argc, char **argv, struct command *acmd, .file = NULL, }; - OPT_ARGS(opts) = { - OPT_FILE("output-file", 'o', &cfg.file, file), - OPT_END() - }; + NVME_ARGS(opts, + OPT_FILE("output-file", 'o', &cfg.file, file)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4892,9 +4882,7 @@ static int wdc_purge(int argc, char **argv, char *err_str; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -4946,9 +4934,7 @@ static int wdc_purge_monitor(int argc, char **argv, __u64 capabilities; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8324,14 +8310,11 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("interval", 'i', &cfg.interval, interval), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), OPT_BYTE("log-page-version", 'l', &cfg.log_page_version, log_page_version), OPT_LIST("log-page-mask", 'p', &cfg.log_page_mask, log_page_mask), - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_END() - }; + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8461,11 +8444,8 @@ static int wdc_cu_smart_log(int argc, char **argv, struct command *acmd, .uuid_index = 0, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_UINT("uuid-index", 'u', &cfg.uuid_index, uuid_index), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("uuid-index", 'u', &cfg.uuid_index, uuid_index)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8572,11 +8552,8 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8642,11 +8619,8 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8733,11 +8707,8 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8841,10 +8812,7 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *ac .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8886,10 +8854,7 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *acm .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8932,10 +8897,7 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *a .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -8978,10 +8940,7 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *a .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9057,9 +9016,7 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma __u64 capabilities = 0; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9105,9 +9062,7 @@ static int wdc_drive_status(int argc, char **argv, struct command *acmd, __u64 capabilities = 0; struct nvme_id_uuid_list uuid_list; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9251,9 +9206,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *acmd, __u64 capabilities = 0; struct nvme_passthru_cmd admin_cmd; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9476,10 +9429,7 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *acm .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9562,9 +9512,7 @@ static int wdc_clear_fw_activate_history(int argc, char **argv, struct command * _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -9617,12 +9565,10 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm .status = false, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FLAG("disable", 'd', &cfg.disable, disable), OPT_FLAG("enable", 'e', &cfg.enable, enable), - OPT_FLAG("status", 's', &cfg.status, status), - OPT_END() - }; + OPT_FLAG("status", 's', &cfg.status, status)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -10410,10 +10356,8 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *acmd, .dirName = NULL, }; - OPT_ARGS(opts) = { - OPT_STRING("dir-name", 'd', "DIRECTORY", &cfg.dirName, dirName), - OPT_END() - }; + NVME_ARGS(opts, + OPT_STRING("dir-name", 'd', "DIRECTORY", &cfg.dirName, dirName)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); @@ -10509,10 +10453,8 @@ static int wdc_drive_resize(int argc, char **argv, .size = 0, }; - OPT_ARGS(opts) = { - OPT_UINT("size", 's', &cfg.size, size), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("size", 's', &cfg.size, size)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -10559,11 +10501,9 @@ static int wdc_namespace_resize(int argc, char **argv, .op_option = 0xF, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_UINT("op-option", 'o', &cfg.op_option, op_option), - OPT_END() - }; + OPT_UINT("op-option", 'o', &cfg.op_option, op_option)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -10621,11 +10561,9 @@ static int wdc_reason_identifier(int argc, char **argv, .file = NULL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("log-id", 'i', &cfg.log_id, log_id), - OPT_FILE("file", 'o', &cfg.file, fname), - OPT_END() - }; + OPT_FILE("file", 'o', &cfg.file, fname)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); @@ -10883,10 +10821,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json|binary"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -11636,10 +11571,7 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -11716,10 +11648,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *acmd, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -11806,10 +11735,7 @@ static int wdc_vs_drive_info(int argc, char **argv, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -12059,10 +11985,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -12164,9 +12087,7 @@ static int wdc_capabilities(int argc, char **argv, struct command *acmd, struct uint64_t capabilities = 0; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -12271,9 +12192,7 @@ static int wdc_cloud_ssd_plugin_version(int argc, char **argv, struct command *a uint64_t capabilities = 0; int ret; - OPT_ARGS(opts) = { - OPT_END() - }; + NVME_ARGS(opts); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -12317,10 +12236,8 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, struct command *acm .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { - OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_END() - }; + NVME_ARGS(opts, + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (ret) @@ -12383,12 +12300,10 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *acmd, struct p .log_id = 0xffffffff, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_FILE("output-file", 'o', &cfg.file, file), OPT_UINT("transfer-size", 's', &cfg.xfer_size, size), - OPT_UINT("log-id", 'l', &cfg.log_id, log), - OPT_END() - }; + OPT_UINT("log-id", 'l', &cfg.log_id, log)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -12679,7 +12594,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, .latency_monitor_feature_enable = 0x7, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("active_bucket_timer_threshold", 't', &cfg.active_bucket_timer_threshold, active_bucket_timer_threshold), @@ -12702,9 +12617,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, discard_debug_log), OPT_UINT("latency_monitor_feature_enable", 'e', &cfg.latency_monitor_feature_enable, - latency_monitor_feature_enable), - OPT_END() - }; + latency_monitor_feature_enable)); ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c index 945b2315bf..b461e7371d 100644 --- a/plugins/ymtc/ymtc-nvme.c +++ b/plugins/ymtc/ymtc-nvme.c @@ -135,11 +135,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, .namespace_id = NVME_NSID_ALL, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace), - OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), - OPT_END() - }; + OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index bac0ad4aa4..a8695c7097 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -144,10 +144,7 @@ static int id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *p .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_END() - }; + NVME_ARGS(opts); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -195,13 +192,10 @@ static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plu .output_format = "normal", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_FLAG("vendor-specific", 'v', &cfg.vendor_specific, vendor_specific), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable), - OPT_END() - }; + OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -261,13 +255,11 @@ static int zns_mgmt_send(int argc, char **argv, struct command *acmd, struct plu struct config cfg = {}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("select-all", 'a', &cfg.select_all, select_all), - OPT_UINT("timeout", 't', &cfg.timeout, timeout), - OPT_END() - }; + OPT_UINT("timeout", 't', &cfg.timeout, timeout)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -365,7 +357,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *acmd, struct pl struct config cfg = {}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("zsaso", 'o', &cfg.zsaso, zsaso), @@ -373,9 +365,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *acmd, struct pl OPT_BYTE("zsa", 'z', &cfg.zsa, zsa), OPT_UINT("data-len", 'l', &cfg.data_len, data_len), OPT_FILE("data", 'd', &cfg.file, data), - OPT_UINT("timeout", 't', &cfg.timeout, timeout), - OPT_END() - }; + OPT_UINT("timeout", 't', &cfg.timeout, timeout)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -490,14 +480,12 @@ static int open_zone(int argc, char **argv, struct command *acmd, struct plugin struct config cfg = { }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("zrwaa", 'r', &cfg.zrwaa, zrwaa), OPT_FLAG("select-all", 'a', &cfg.select_all, select_all), - OPT_UINT("timeout", 't', &cfg.timeout, timeout), - OPT_END() - }; + OPT_UINT("timeout", 't', &cfg.timeout, timeout)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -565,14 +553,12 @@ static int set_zone_desc(int argc, char **argv, struct command *acmd, struct plu struct config cfg = {}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("zrwaa", 'r', &cfg.zrwaa, zrwaa), OPT_FILE("data", 'd', &cfg.file, data), - OPT_UINT("timeout", 't', &cfg.timeout, timeout), - OPT_END() - }; + OPT_UINT("timeout", 't', &cfg.timeout, timeout)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -654,12 +640,10 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *acmd, struct p struct config cfg = {}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("lba", 'l', &cfg.lba, slba), - OPT_UINT("timeout", 't', &cfg.timeout, timeout), - OPT_END() - }; + OPT_UINT("timeout", 't', &cfg.timeout, timeout)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -717,16 +701,13 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *acmd, struct pl .output_format = "normal", }; - OPT_ARGS(opts) = { - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_BYTE("zra", 'z', &cfg.zra, zra), OPT_BYTE("zrasf", 'S', &cfg.zrasf, zrasf), OPT_FLAG("partial", 'p', &cfg.partial, partial), - OPT_UINT("data-len", 'l', &cfg.data_len, data_len), - OPT_END() - }; + OPT_UINT("data-len", 'l', &cfg.data_len, data_len)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -819,17 +800,14 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug .num_descs = -1, }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_UINT("descs", 'd', &cfg.num_descs, num_descs), OPT_UINT("state", 'S', &cfg.state, state), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), OPT_FLAG("verbose", 'v', &cfg.verbose, verbose), OPT_FLAG("extended", 'e', &cfg.extended, ext), - OPT_FLAG("partial", 'p', &cfg.partial, part), - OPT_END() - }; + OPT_FLAG("partial", 'p', &cfg.partial, part)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -992,7 +970,7 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi struct config cfg = {}; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("zslba", 's', &cfg.zslba, zslba), OPT_SUFFIX("data-size", 'z', &cfg.data_size, data_size), @@ -1003,9 +981,7 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi OPT_FLAG("force-unit-access", 'f', &cfg.fua, fua), OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo), OPT_FLAG("piremap", 'P', &cfg.piremap, piremap), - OPT_FLAG("latency", 't', &cfg.latency, latency), - OPT_END() - }; + OPT_FLAG("latency", 't', &cfg.latency, latency)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err) @@ -1161,12 +1137,9 @@ static int changed_zone_list(int argc, char **argv, struct command *acmd, struct .output_format = "normal", }; - OPT_ARGS(opts) = { + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), - OPT_FMT("output-format", 'o', &cfg.output_format, output_format), - OPT_FLAG("rae", 'r', &cfg.rae, rae), - OPT_END() - }; + OPT_FLAG("rae", 'r', &cfg.rae, rae)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); if (err)