Date: Sun, 2 Dec 2018 23:12:59 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341412 - head/sbin/nvmecontrol Message-ID: <201812022312.wB2NCxM4037866@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Sun Dec 2 23:12:58 2018 New Revision: 341412 URL: https://svnweb.freebsd.org/changeset/base/341412 Log: Usage cleanup pt 1 Provide a usage() function that takes a struct nvme_function pointer and produces a usage mssage. Eliminate all now-redundant usage functions. Propigate the new argument through the program as needed. Use common routine to print usage. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D18403 Modified: head/sbin/nvmecontrol/devlist.c head/sbin/nvmecontrol/firmware.c head/sbin/nvmecontrol/format.c head/sbin/nvmecontrol/identify.c head/sbin/nvmecontrol/logpage.c head/sbin/nvmecontrol/ns.c head/sbin/nvmecontrol/nvmecontrol.c head/sbin/nvmecontrol/nvmecontrol.h head/sbin/nvmecontrol/perftest.c head/sbin/nvmecontrol/power.c head/sbin/nvmecontrol/reset.c head/sbin/nvmecontrol/wdc.c Modified: head/sbin/nvmecontrol/devlist.c ============================================================================== --- head/sbin/nvmecontrol/devlist.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/devlist.c Sun Dec 2 23:12:58 2018 (r341412) @@ -46,14 +46,6 @@ __FBSDID("$FreeBSD$"); #define DEVLIST_USAGE \ " nvmecontrol devlist\n" -static void -devlist_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, DEVLIST_USAGE); - exit(1); -} - static inline uint32_t ns_get_sector_size(struct nvme_namespace_data *nsdata) { @@ -68,7 +60,7 @@ ns_get_sector_size(struct nvme_namespace_data *nsdata) } static void -devlist(int argc, char *argv[]) +devlist(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cdata; struct nvme_namespace_data nsdata; @@ -80,7 +72,7 @@ devlist(int argc, char *argv[]) while ((ch = getopt(argc, argv, "")) != -1) { switch ((char)ch) { default: - devlist_usage(); + usage(nf); } } Modified: head/sbin/nvmecontrol/firmware.c ============================================================================== --- head/sbin/nvmecontrol/firmware.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/firmware.c Sun Dec 2 23:12:58 2018 (r341412) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #define FIRMWARE_USAGE \ " nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n" - static int slot_has_valid_firmware(int fd, int slot) { @@ -175,16 +174,8 @@ activate_firmware(int fd, int slot, int activate_actio } static void -firmware_usage(void) +firmware(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, FIRMWARE_USAGE); - exit(1); -} - -static void -firmware(int argc, char *argv[]) -{ int fd = -1, slot = 0; int a_flag, s_flag, f_flag; int activate_action, reboot_required; @@ -210,18 +201,18 @@ firmware(int argc, char *argv[]) fprintf(stderr, "\"%s\" not valid slot.\n", optarg); - firmware_usage(); + usage(nf); } else if (slot == 0) { fprintf(stderr, "0 is not a valid slot number. " "Slot numbers start at 1.\n"); - firmware_usage(); + usage(nf); } else if (slot > 7) { fprintf(stderr, "Slot number %s specified which is " "greater than max allowed slot number of " "7.\n", optarg); - firmware_usage(); + usage(nf); } s_flag = true; break; @@ -234,20 +225,20 @@ firmware(int argc, char *argv[]) /* Check that a controller (and not a namespace) was specified. */ if (optind >= argc || strstr(argv[optind], NVME_NS_PREFIX) != NULL) - firmware_usage(); + usage(nf); if (!f_flag && !a_flag) { fprintf(stderr, "Neither a replace ([-f path_to_firmware]) nor " "activate ([-a]) firmware image action\n" "was specified.\n"); - firmware_usage(); + usage(nf); } if (!f_flag && a_flag && slot == 0) { fprintf(stderr, "Slot number to activate not specified.\n"); - firmware_usage(); + usage(nf); } controller = argv[optind]; Modified: head/sbin/nvmecontrol/format.c ============================================================================== --- head/sbin/nvmecontrol/format.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/format.c Sun Dec 2 23:12:58 2018 (r341412) @@ -47,16 +47,8 @@ __FBSDID("$FreeBSD$"); " nvmecontrol format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n" static void -format_usage(void) +format(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, FORMAT_USAGE); - exit(1); -} - -static void -format(int argc, char *argv[]) -{ struct nvme_controller_data cd; struct nvme_namespace_data nsd; struct nvme_pt_command pt; @@ -67,7 +59,7 @@ format(int argc, char *argv[]) int lbaf = -1, mset = -1, pi = -1, pil = -1, ses = 0; if (argc < 2) - format_usage(); + usage(nf); while ((ch = getopt(argc, argv, "f:m:p:l:EC")) != -1) { switch ((char)ch) { @@ -94,13 +86,13 @@ format(int argc, char *argv[]) ses = 2; break; default: - format_usage(); + usage(nf); } } /* Check that a controller or namespace was specified. */ if (optind >= argc) - format_usage(); + usage(nf); target = argv[optind]; /* Modified: head/sbin/nvmecontrol/identify.c ============================================================================== --- head/sbin/nvmecontrol/identify.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/identify.c Sun Dec 2 23:12:58 2018 (r341412) @@ -150,16 +150,8 @@ print_namespace(struct nvme_namespace_data *nsdata) } static void -identify_usage(void) +identify_ctrlr(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, IDENTIFY_USAGE); - exit(1); -} - -static void -identify_ctrlr(int argc, char *argv[]) -{ struct nvme_controller_data cdata; int ch, fd, hexflag = 0, hexlength; int verboseflag = 0; @@ -173,13 +165,13 @@ identify_ctrlr(int argc, char *argv[]) hexflag = 1; break; default: - identify_usage(); + usage(nf); } } /* Check that a controller was specified. */ if (optind >= argc) - identify_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); read_controller_data(fd, &cdata); @@ -197,7 +189,7 @@ identify_ctrlr(int argc, char *argv[]) if (verboseflag == 1) { fprintf(stderr, "-v not currently supported without -x\n"); - identify_usage(); + usage(nf); } nvme_print_controller(&cdata); @@ -205,7 +197,7 @@ identify_ctrlr(int argc, char *argv[]) } static void -identify_ns(int argc, char *argv[]) +identify_ns(struct nvme_function *nf,int argc, char *argv[]) { struct nvme_namespace_data nsdata; char path[64]; @@ -222,13 +214,13 @@ identify_ns(int argc, char *argv[]) hexflag = 1; break; default: - identify_usage(); + usage(nf); } } /* Check that a namespace was specified. */ if (optind >= argc) - identify_usage(); + usage(nf); /* * Check if the specified device node exists before continuing. @@ -261,7 +253,7 @@ identify_ns(int argc, char *argv[]) if (verboseflag == 1) { fprintf(stderr, "-v not currently supported without -x\n"); - identify_usage(); + usage(nf); } print_namespace(&nsdata); @@ -269,18 +261,18 @@ identify_ns(int argc, char *argv[]) } static void -identify(int argc, char *argv[]) +identify(struct nvme_function *nf, int argc, char *argv[]) { char *target; if (argc < 2) - identify_usage(); + usage(nf); while (getopt(argc, argv, "vx") != -1) ; /* Check that a controller or namespace was specified. */ if (optind >= argc) - identify_usage(); + usage(nf); target = argv[optind]; @@ -292,9 +284,9 @@ identify(int argc, char *argv[]) * otherwise, consider it a controller. */ if (strstr(target, NVME_NS_PREFIX) == NULL) - identify_ctrlr(argc, argv); + identify_ctrlr(nf, argc, argv); else - identify_ns(argc, argv); + identify_ns(nf, argc, argv); } NVME_COMMAND(top, identify, identify, IDENTIFY_USAGE); Modified: head/sbin/nvmecontrol/logpage.c ============================================================================== --- head/sbin/nvmecontrol/logpage.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/logpage.c Sun Dec 2 23:12:58 2018 (r341412) @@ -473,14 +473,6 @@ NVME_LOGPAGE(samsung_smart, print_intel_add_smart, DEFAULT_SIZE); static void -logpage_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, LOGPAGE_USAGE); - exit(1); -} - -static void logpage_help(void) { struct logpage_function **f; @@ -498,7 +490,7 @@ logpage_help(void) } static void -logpage(int argc, char *argv[]) +logpage(struct nvme_function *nf, int argc, char *argv[]) { int fd; int log_page = 0, pageflag = false; @@ -529,7 +521,7 @@ logpage(int argc, char *argv[]) fprintf(stderr, "\"%s\" not valid log page id.\n", optarg); - logpage_usage(); + usage(nf); } pageflag = true; break; @@ -546,12 +538,12 @@ logpage(int argc, char *argv[]) if (!pageflag) { printf("Missing page_id (-p).\n"); - logpage_usage(); + usage(nf); } /* Check that a controller and/or namespace was specified. */ if (optind >= argc) - logpage_usage(); + usage(nf); if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) { ns_specified = true; Modified: head/sbin/nvmecontrol/ns.c ============================================================================== --- head/sbin/nvmecontrol/ns.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/ns.c Sun Dec 2 23:12:58 2018 (r341412) @@ -60,48 +60,16 @@ SET_DECLARE(ns, struct nvme_function); #define NSDETACH_USAGE \ " nvmecontrol ns detach -n nsid [-c ctrlrid] nvmeN\n" -void nscreate(int argc, char *argv[]); -void nsdelete(int argc, char *argv[]); -void nsattach(int argc, char *argv[]); -void nsdetach(int argc, char *argv[]); +void nscreate(struct nvme_function *nf, int argc, char *argv[]); +void nsdelete(struct nvme_function *nf, int argc, char *argv[]); +void nsattach(struct nvme_function *nf, int argc, char *argv[]); +void nsdetach(struct nvme_function *nf, int argc, char *argv[]); NVME_COMMAND(ns, create, nscreate, NSCREATE_USAGE); NVME_COMMAND(ns, delete, nsdelete, NSDELETE_USAGE); NVME_COMMAND(ns, attach, nsattach, NSATTACH_USAGE); NVME_COMMAND(ns, detach, nsdetach, NSDETACH_USAGE); -static void -nscreate_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, NSCREATE_USAGE); - exit(1); -} - -static void -nsdelete_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, NSDELETE_USAGE); - exit(1); -} - -static void -nsattach_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, NSATTACH_USAGE); - exit(1); -} - -static void -nsdetach_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, NSDETACH_USAGE); - exit(1); -} - struct ns_result_str { uint16_t res; const char * str; @@ -142,7 +110,7 @@ get_res_str(uint16_t res) * 0xb = Thin Provisioning Not supported */ void -nscreate(int argc, char *argv[]) +nscreate(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -151,7 +119,7 @@ nscreate(int argc, char *argv[]) int ch, fd, result, lbaf = 0, mset = 0, nmic = -1, pi = 0, pil = 0; if (optind >= argc) - nscreate_usage(); + usage(nf); while ((ch = getopt(argc, argv, "s:c:f:m:n:p:l:")) != -1) { switch (ch) { @@ -177,17 +145,17 @@ nscreate(int argc, char *argv[]) pil = strtol(optarg, NULL, 0); break; default: - nscreate_usage(); + usage(nf); } } if (optind >= argc) - nscreate_usage(); + usage(nf); if (cap == -1) cap = nsze; if (nsze == -1 || cap == -1) - nscreate_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); read_controller_data(fd, &cd); @@ -237,7 +205,7 @@ nscreate(int argc, char *argv[]) } void -nsdelete(int argc, char *argv[]) +nsdelete(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -245,7 +213,7 @@ nsdelete(int argc, char *argv[]) char buf[2]; if (optind >= argc) - nsdelete_usage(); + usage(nf); while ((ch = getopt(argc, argv, "n:")) != -1) { switch ((char)ch) { @@ -253,12 +221,12 @@ nsdelete(int argc, char *argv[]) nsid = strtol(optarg, (char **)NULL, 0); break; default: - nsdelete_usage(); + usage(nf); } } if (optind >= argc || nsid == -2) - nsdelete_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); read_controller_data(fd, &cd); @@ -304,7 +272,7 @@ nsdelete(int argc, char *argv[]) * 0x2 Invalid Field can occur if ctrlrid d.n.e in system. */ void -nsattach(int argc, char *argv[]) +nsattach(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -313,7 +281,7 @@ nsattach(int argc, char *argv[]) uint16_t clist[2048]; if (optind >= argc) - nsattach_usage(); + usage(nf); while ((ch = getopt(argc, argv, "n:c:")) != -1) { switch (ch) { @@ -324,15 +292,15 @@ nsattach(int argc, char *argv[]) ctrlrid = strtol(optarg, (char **)NULL, 0); break; default: - nsattach_usage(); + usage(nf); } } if (optind >= argc) - nsattach_usage(); + usage(nf); if (nsid == -1 ) - nsattach_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); read_controller_data(fd, &cd); @@ -383,7 +351,7 @@ nsattach(int argc, char *argv[]) } void -nsdetach(int argc, char *argv[]) +nsdetach(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -392,7 +360,7 @@ nsdetach(int argc, char *argv[]) uint16_t clist[2048]; if (optind >= argc) - nsdetach_usage(); + usage(nf); while ((ch = getopt(argc, argv, "n:c:")) != -1) { switch (ch) { @@ -403,15 +371,15 @@ nsdetach(int argc, char *argv[]) ctrlrid = strtol(optarg, (char **)NULL, 0); break; default: - nsdetach_usage(); + usage(nf); } } if (optind >= argc) - nsdetach_usage(); + usage(nf); if (nsid == -1) - nsdetach_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); read_controller_data(fd, &cd); @@ -469,7 +437,7 @@ nsdetach(int argc, char *argv[]) } static void -ns(int argc, char *argv[]) +ns(struct nvme_function *nf __unused, int argc, char *argv[]) { DISPATCH(argc, argv, ns); Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/nvmecontrol.c Sun Dec 2 23:12:58 2018 (r341412) @@ -50,18 +50,33 @@ __FBSDID("$FreeBSD$"); SET_DECLARE(top, struct nvme_function); static void +print_usage(const struct nvme_function *f) +{ + fprintf(stderr, "%s", f->usage); +} + +static void gen_usage_set(struct nvme_function **f, struct nvme_function **flimit) { fprintf(stderr, "usage:\n"); while (f < flimit) { - fprintf(stderr, "%s", (*f)->usage); + print_usage(*f); f++; } exit(1); } void +usage(const struct nvme_function *f) +{ + + fprintf(stderr, "usage:\n"); + print_usage(f); + exit(1); +} + +void dispatch_set(int argc, char *argv[], struct nvme_function **tbl, struct nvme_function **tbl_limit) { @@ -74,7 +89,7 @@ dispatch_set(int argc, char *argv[], struct nvme_funct while (f < tbl_limit) { if (strcmp(argv[1], (*f)->name) == 0) { - (*f)->fn(argc-1, &argv[1]); + (*f)->fn(*f, argc-1, &argv[1]); return; } f++; Modified: head/sbin/nvmecontrol/nvmecontrol.h ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.h Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/nvmecontrol.h Sun Dec 2 23:12:58 2018 (r341412) @@ -34,7 +34,8 @@ #include <sys/linker_set.h> #include <dev/nvme/nvme.h> -typedef void (*nvme_fn_t)(int argc, char *argv[]); +struct nvme_function; +typedef void (*nvme_fn_t)(struct nvme_function *nf, int argc, char *argv[]); struct nvme_function { const char *name; @@ -88,6 +89,7 @@ void print_hex(void *data, uint32_t length); void read_logpage(int fd, uint8_t log_page, uint32_t nsid, void *payload, uint32_t payload_size); +void usage(const struct nvme_function *f); void dispatch_set(int argc, char *argv[], struct nvme_function **tbl, struct nvme_function **tbl_limit); Modified: head/sbin/nvmecontrol/perftest.c ============================================================================== --- head/sbin/nvmecontrol/perftest.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/perftest.c Sun Dec 2 23:12:58 2018 (r341412) @@ -75,16 +75,8 @@ print_perftest(struct nvme_io_test *io_test, bool pert } static void -perftest_usage(void) +perftest(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, PERFTEST_USAGE); - exit(1); -} - -static void -perftest(int argc, char *argv[]) -{ struct nvme_io_test io_test; int fd; int opt; @@ -118,13 +110,13 @@ perftest(int argc, char *argv[]) fprintf(stderr, "\"%s\" not valid number of threads.\n", optarg); - perftest_usage(); + usage(nf); } else if (io_test.num_threads == 0 || io_test.num_threads > 128) { fprintf(stderr, "\"%s\" not valid number of threads.\n", optarg); - perftest_usage(); + usage(nf); } break; case 'o': @@ -137,7 +129,7 @@ perftest(int argc, char *argv[]) else { fprintf(stderr, "\"%s\" not valid opcode.\n", optarg); - perftest_usage(); + usage(nf); } break; case 'p': @@ -155,7 +147,7 @@ perftest(int argc, char *argv[]) } else { fprintf(stderr, "\"%s\" not valid size.\n", optarg); - perftest_usage(); + usage(nf); } break; case 't': @@ -165,14 +157,15 @@ perftest(int argc, char *argv[]) fprintf(stderr, "\"%s\" not valid time duration.\n", optarg); - perftest_usage(); + usage(nf); } break; } } if (!nflag || !oflag || !sflag || !tflag || optind >= argc) - perftest_usage(); + usage(nf); + open_dev(argv[optind], &fd, 1, 1); if (ioctl(fd, ioctl_cmd, &io_test) < 0) Modified: head/sbin/nvmecontrol/power.c ============================================================================== --- head/sbin/nvmecontrol/power.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/power.c Sun Dec 2 23:12:58 2018 (r341412) @@ -48,14 +48,6 @@ _Static_assert(sizeof(struct nvme_power_state) == 256 " nvmecontrol power [-l] [-p new-state [-w workload-hint]] <controller id>\n" static void -power_usage(void) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, POWER_USAGE); - exit(1); -} - -static void power_list_one(int i, struct nvme_power_state *nps) { int mpower, apower, ipower; @@ -137,7 +129,7 @@ power_show(int fd) } static void -power(int argc, char *argv[]) +power(struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cdata; int ch, listflag = 0, powerflag = 0, power_val = 0, fd; @@ -154,28 +146,28 @@ power(int argc, char *argv[]) power_val = strtol(optarg, &end, 0); if (*end != '\0') { fprintf(stderr, "Invalid power state number: %s\n", optarg); - power_usage(); + usage(nf); } break; case 'w': workload = strtol(optarg, &end, 0); if (*end != '\0') { fprintf(stderr, "Invalid workload hint: %s\n", optarg); - power_usage(); + usage(nf); } break; default: - power_usage(); + usage(nf); } } /* Check that a controller was specified. */ if (optind >= argc) - power_usage(); + usage(nf); if (listflag && powerflag) { fprintf(stderr, "Can't set power and list power states\n"); - power_usage(); + usage(nf); } open_dev(argv[optind], &fd, 1, 1); Modified: head/sbin/nvmecontrol/reset.c ============================================================================== --- head/sbin/nvmecontrol/reset.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/reset.c Sun Dec 2 23:12:58 2018 (r341412) @@ -45,28 +45,20 @@ __FBSDID("$FreeBSD$"); " nvmecontrol reset <controller id>\n" static void -reset_usage(void) +reset(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, RESET_USAGE); - exit(1); -} - -static void -reset(int argc, char *argv[]) -{ int ch, fd; while ((ch = getopt(argc, argv, "")) != -1) { switch ((char)ch) { default: - reset_usage(); + usage(nf); } } /* Check that a controller was specified. */ if (optind >= argc) - reset_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) Modified: head/sbin/nvmecontrol/wdc.c ============================================================================== --- head/sbin/nvmecontrol/wdc.c Sun Dec 2 23:12:48 2018 (r341411) +++ head/sbin/nvmecontrol/wdc.c Sun Dec 2 23:12:58 2018 (r341412) @@ -52,7 +52,7 @@ SET_DECLARE(wdc, struct nvme_function); #define WDC_NVME_CAP_DIAG_OPCODE 0xe6 #define WDC_NVME_CAP_DIAG_CMD 0x0000 -static void wdc_cap_diag(int argc, char *argv[]); +static void wdc_cap_diag(struct nvme_function *nf, int argc, char *argv[]); #define WDC_CAP_DIAG_USAGE "\tnvmecontrol wdc cap-diag [-o path-template]\n" @@ -154,16 +154,8 @@ wdc_do_dump(int fd, char *tmpl, const char *suffix, ui } static void -wdc_cap_diag_usage(void) +wdc_cap_diag(struct nvme_function *nf, int argc, char *argv[]) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, WDC_CAP_DIAG_USAGE); - exit(1); -} - -static void -wdc_cap_diag(int argc, char *argv[]) -{ char path_tmpl[MAXPATHLEN]; int ch, fd; @@ -174,12 +166,12 @@ wdc_cap_diag(int argc, char *argv[]) strlcpy(path_tmpl, optarg, MAXPATHLEN); break; default: - wdc_cap_diag_usage(); + usage(nf); } } /* Check that a controller was specified. */ if (optind >= argc) - wdc_cap_diag_usage(); + usage(nf); open_dev(argv[optind], &fd, 1, 1); wdc_do_dump(fd, path_tmpl, "cap_diag", WDC_NVME_CAP_DIAG_OPCODE, @@ -191,7 +183,7 @@ wdc_cap_diag(int argc, char *argv[]) } static void -wdc(int argc, char *argv[]) +wdc(struct nvme_function *nf __unused, int argc, char *argv[]) { DISPATCH(argc, argv, wdc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812022312.wB2NCxM4037866>