Skip to content

Commit 086491b

Browse files
Copilotigaw
andcommitted
Convert OPT_ARGS to NVME_ARGS in nvme-cli codebase
Co-authored-by: igaw <[email protected]>
1 parent b4206b8 commit 086491b

43 files changed

Lines changed: 332 additions & 774 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.build-tools/samurai

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 737f702fed670acb25e5e70b4b802690df7a4a8b

fabrics.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,9 @@ int fabrics_disconnect(const char *desc, int argc, char **argv)
751751

752752
struct config cfg = { 0 };
753753

754-
OPT_ARGS(opts) = {
754+
NVME_ARGS(opts,
755755
OPT_STRING("nqn", 'n', "NAME", &cfg.nqn, nvmf_nqn),
756-
OPT_STRING("device", 'd', "DEV", &cfg.device, device),
757-
OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"),
758-
OPT_END()
759-
};
756+
OPT_STRING("device", 'd', "DEV", &cfg.device, device));
760757

761758
ret = argconfig_parse(argc, argv, desc, opts);
762759
if (ret)
@@ -839,11 +836,8 @@ int fabrics_disconnect_all(const char *desc, int argc, char **argv)
839836

840837
struct config cfg = { 0 };
841838

842-
OPT_ARGS(opts) = {
843-
OPT_STRING("transport", 'r', "STR", (char *)&cfg.transport, nvmf_tport),
844-
OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"),
845-
OPT_END()
846-
};
839+
NVME_ARGS(opts,
840+
OPT_STRING("transport", 'r', "STR", (char *)&cfg.transport, nvmf_tport));
847841

848842
ret = argconfig_parse(argc, argv, desc, opts);
849843
if (ret)
@@ -1018,13 +1012,10 @@ int fabrics_dim(const char *desc, int argc, char **argv)
10181012
unsigned int verbose;
10191013
} cfg = { 0 };
10201014

1021-
OPT_ARGS(opts) = {
1015+
NVME_ARGS(opts,
10221016
OPT_STRING("nqn", 'n', "NAME", &cfg.nqn, "Comma-separated list of DC nqn"),
10231017
OPT_STRING("device", 'd', "DEV", &cfg.device, "Comma-separated list of DC nvme device handle."),
1024-
OPT_STRING("task", 't', "TASK", &cfg.tas, "[register|deregister]"),
1025-
OPT_INCR("verbose", 'v', &cfg.verbose, "Increase logging verbosity"),
1026-
OPT_END()
1027-
};
1018+
OPT_STRING("task", 't', "TASK", &cfg.tas, "[register|deregister]"));
10281019

10291020
ret = argconfig_parse(argc, argv, desc, opts);
10301021
if (ret)

nvme-rpmb.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,17 +855,15 @@ int rpmb_cmd_option(int argc, char **argv, struct command *acmd, struct plugin *
855855
.target = 0,
856856
};
857857

858-
OPT_ARGS(opts) = {
858+
NVME_ARGS(opts,
859859
OPT_STRING("cmd", 'c', "command", &cfg.cmd, opt),
860860
OPT_STRING("msgfile", 'f', "FILE", &cfg.msgfile, mfile),
861861
OPT_STRING("keyfile", 'g', "FILE", &cfg.keyfile, kfile),
862862
OPT_STRING("key", 'k', "key", &cfg.key, key),
863863
OPT_STRING("msg", 'd', "data", &cfg.msg, msg),
864864
OPT_UINT("address", 'o', &cfg.address, address),
865865
OPT_UINT("blocks", 'b', &cfg.blocks, blocks),
866-
OPT_UINT("target", 't', &cfg.target, target),
867-
OPT_END()
868-
};
866+
OPT_UINT("target", 't', &cfg.target, target));
869867

870868
_cleanup_free_ unsigned char *key_buf = NULL;
871869
_cleanup_free_ unsigned char *msg_buf = NULL;

plugins/amzn/amzn-nvme.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,8 @@ static int get_stats(int argc, char **argv, struct command *acmd,
485485
.output_format = "normal",
486486
};
487487

488-
OPT_ARGS(opts) = {
489-
OPT_FMT("output-format", 'o', &cfg.output_format,
490-
"Output Format: normal|json"),
491-
OPT_FLAG("details", 'd', &detail, "Detail IO histogram of each block size ranges"),
492-
OPT_END()};
488+
NVME_ARGS(opts,
489+
OPT_FLAG("details", 'd', &detail, "Detail IO histogram of each block size ranges"));
493490

494491
rc = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
495492
if (rc)

plugins/dapustor/dapustor-nvme.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,10 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command *
526526
.namespace_id = NVME_NSID_ALL,
527527
};
528528

529-
OPT_ARGS(opts) = {
529+
NVME_ARGS(opts,
530530
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
531531
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
532-
OPT_FLAG_JSON("json", 'j', &cfg.json, json),
533-
OPT_END()
534-
};
532+
OPT_FLAG_JSON("json", 'j', &cfg.json, json));
535533

536534
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
537535
if (err)

plugins/dera/dera-nvme.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ static int get_status(int argc, char **argv, struct command *acmd, struct plugin
123123
struct nvme_dera_smart_info_log log;
124124
int err;
125125

126-
OPT_ARGS(opts) = {
127-
OPT_END()
128-
};
126+
NVME_ARGS(opts);
129127

130128
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
131129
if (err)

plugins/fdp/fdp.c

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,10 @@ static int fdp_configs(int argc, char **argv, struct command *acmd,
4545
.raw_binary = false,
4646
};
4747

48-
OPT_ARGS(opts) = {
48+
NVME_ARGS(opts,
4949
OPT_UINT("endgrp-id", 'e', &cfg.egid, egid),
50-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
5150
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
52-
OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
53-
OPT_END()
54-
};
51+
OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable));
5552

5653
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5754
if (err)
@@ -120,12 +117,9 @@ static int fdp_usage(int argc, char **argv, struct command *acmd, struct plugin
120117
.raw_binary = false,
121118
};
122119

123-
OPT_ARGS(opts) = {
120+
NVME_ARGS(opts,
124121
OPT_UINT("endgrp-id", 'e', &cfg.egid, egid),
125-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
126-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
127-
OPT_END()
128-
};
122+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
129123

130124
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
131125
if (err)
@@ -186,12 +180,9 @@ static int fdp_stats(int argc, char **argv, struct command *acmd, struct plugin
186180
.raw_binary = false,
187181
};
188182

189-
OPT_ARGS(opts) = {
183+
NVME_ARGS(opts,
190184
OPT_UINT("endgrp-id", 'e', &cfg.egid, egid),
191-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
192-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
193-
OPT_END()
194-
};
185+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
195186

196187
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
197188
if (err)
@@ -249,13 +240,10 @@ static int fdp_events(int argc, char **argv, struct command *acmd, struct plugin
249240
.raw_binary = false,
250241
};
251242

252-
OPT_ARGS(opts) = {
243+
NVME_ARGS(opts,
253244
OPT_UINT("endgrp-id", 'e', &cfg.egid, egid),
254245
OPT_FLAG("host-events", 'E', &cfg.host_events, host_events),
255-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
256-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
257-
OPT_END()
258-
};
246+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
259247

260248
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
261249
if (err)
@@ -313,12 +301,9 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin
313301
.raw_binary = false,
314302
};
315303

316-
OPT_ARGS(opts) = {
304+
NVME_ARGS(opts,
317305
OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id),
318-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
319-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
320-
OPT_END()
321-
};
306+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
322307

323308
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
324309
if (err)
@@ -388,11 +373,9 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin
388373
.pids = "",
389374
};
390375

391-
OPT_ARGS(opts) = {
376+
NVME_ARGS(opts,
392377
OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id),
393-
OPT_LIST("pids", 'p', &cfg.pids, _pids),
394-
OPT_END()
395-
};
378+
OPT_LIST("pids", 'p', &cfg.pids, _pids));
396379

397380
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
398381
if (err)
@@ -459,14 +442,12 @@ static int fdp_set_events(int argc, char **argv, struct command *acmd, struct pl
459442
.sv = false,
460443
};
461444

462-
OPT_ARGS(opts) = {
445+
NVME_ARGS(opts,
463446
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
464447
OPT_SHRT("placement-handle", 'p', &cfg.ph, ph),
465448
OPT_FLAG("enable", 'e', &cfg.enable, enable),
466449
OPT_FLAG("save", 's', &cfg.sv, sv),
467-
OPT_LIST("event-types", 't', &cfg.event_types, event_types),
468-
OPT_END()
469-
};
450+
OPT_LIST("event-types", 't', &cfg.event_types, event_types));
470451

471452
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
472453
if (err)
@@ -537,13 +518,10 @@ static int fdp_feature(int argc, char **argv, struct command *acmd, struct plugi
537518
.endgid = 0,
538519
};
539520

540-
OPT_ARGS(opts) = {
521+
NVME_ARGS(opts,
541522
OPT_SHRT("endgrp-id", 'e', &cfg.endgid, endurance_group),
542523
OPT_BYTE("enable-conf-idx", 'c', &cfg.fdpcidx, enable_conf_idx),
543-
OPT_FLAG("disable", 'd', &cfg.disable, disable),
544-
OPT_INCR("verbose", 'v', &nvme_cfg.verbose, verbose),
545-
OPT_END()
546-
};
524+
OPT_FLAG("disable", 'd', &cfg.disable, disable));
547525

548526
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
549527
if (err)

plugins/huawei/huawei-nvme.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,7 @@ static int huawei_list(int argc, char **argv, struct command *acmd,
311311
.output_format = "normal",
312312
};
313313

314-
OPT_ARGS(opts) = {
315-
OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"),
316-
OPT_END()
317-
};
314+
NVME_ARGS(opts);
318315

319316
if (!ctx)
320317
return -ENOMEM;

plugins/ibm/ibm-nvme.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,8 @@ static int get_ibm_addi_smart_log(int argc, char **argv, struct command *cmd, st
236236
.raw_binary = 0,
237237
};
238238

239-
OPT_ARGS(opts) = {
240-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
241-
OPT_END()
242-
};
239+
NVME_ARGS(opts,
240+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
243241

244242
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
245243
if (err)
@@ -368,10 +366,8 @@ static int get_ibm_vpd_log(int argc, char **argv, struct command *cmd, struct pl
368366
.raw_binary = 0,
369367
};
370368

371-
OPT_ARGS(opts) = {
372-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
373-
OPT_END()
374-
};
369+
NVME_ARGS(opts,
370+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw));
375371

376372
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
377373
if (err < 0)
@@ -549,13 +545,10 @@ static int get_ibm_persistent_event_log(int argc, char **argv,
549545
.raw_binary = false,
550546
};
551547

552-
OPT_ARGS(opts) = {
548+
NVME_ARGS(opts,
553549
OPT_BYTE("action", 'a', &cfg.action, action),
554550
OPT_UINT("log_len", 'l', &cfg.log_len, log_len),
555-
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
556-
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use),
557-
OPT_END()
558-
};
551+
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use));
559552

560553
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
561554
if (err)

plugins/innogrit/innogrit-nvme.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ static int innogrit_geteventlog(int argc, char **argv,
181181
time_t timep;
182182
int ret = -1;
183183

184-
OPT_ARGS(opts) = {
185-
OPT_END()
186-
};
184+
NVME_ARGS(opts);
187185

188186
ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
189187
if (ret)
@@ -228,9 +226,7 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *acmd,
228226
time_t timep;
229227
int ret = -1;
230228

231-
OPT_ARGS(opts) = {
232-
OPT_END()
233-
};
229+
NVME_ARGS(opts);
234230

235231
ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
236232
if (ret)

0 commit comments

Comments
 (0)