Date: Sun, 2 Dec 2018 23:13:12 +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: r341413 - head/sbin/nvmecontrol Message-ID: <201812022313.wB2NDCtR037938@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Sun Dec 2 23:13:12 2018 New Revision: 341413 URL: https://svnweb.freebsd.org/changeset/base/341413 Log: Usage cleanup pt 2 Eliminage redundant spaces and nvmecontrol at start of all the usage strings. Update the usage printing code to add them back when presenting to the user. Allow multi-line usage messages and print proper leading spaces for lines starting with a space. 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/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:58 2018 (r341412) +++ head/sbin/nvmecontrol/devlist.c Sun Dec 2 23:13:12 2018 (r341413) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define DEVLIST_USAGE \ -" nvmecontrol devlist\n" + "devlist\n" static inline uint32_t ns_get_sector_size(struct nvme_namespace_data *nsdata) Modified: head/sbin/nvmecontrol/firmware.c ============================================================================== --- head/sbin/nvmecontrol/firmware.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/firmware.c Sun Dec 2 23:13:12 2018 (r341413) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define FIRMWARE_USAGE \ -" nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n" + "firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n" static int slot_has_valid_firmware(int fd, int slot) Modified: head/sbin/nvmecontrol/format.c ============================================================================== --- head/sbin/nvmecontrol/format.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/format.c Sun Dec 2 23:13:12 2018 (r341413) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define FORMAT_USAGE \ -" nvmecontrol format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n" + "format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n" static void format(struct nvme_function *nf, int argc, char *argv[]) Modified: head/sbin/nvmecontrol/identify.c ============================================================================== --- head/sbin/nvmecontrol/identify.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/identify.c Sun Dec 2 23:13:12 2018 (r341413) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol_ext.h" #define IDENTIFY_USAGE \ -" nvmecontrol identify [-x [-v]] <controller id|namespace id>\n" + "identify [-x [-v]] <controller id|namespace id>\n" static void print_namespace(struct nvme_namespace_data *nsdata) Modified: head/sbin/nvmecontrol/logpage.c ============================================================================== --- head/sbin/nvmecontrol/logpage.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/logpage.c Sun Dec 2 23:13:12 2018 (r341413) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); SET_DECLARE(logpage, struct logpage_function); #define LOGPAGE_USAGE \ -" nvmecontrol logpage <-p page_id> [-b] [-v vendor] [-x] <controller id|namespace id>\n" \ + "logpage <-p page_id> [-b] [-v vendor] [-x] <controller id|namespace id>\n" \ #define MAX_FW_SLOTS (7) Modified: head/sbin/nvmecontrol/ns.c ============================================================================== --- head/sbin/nvmecontrol/ns.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/ns.c Sun Dec 2 23:13:12 2018 (r341413) @@ -43,22 +43,22 @@ __FBSDID("$FreeBSD$"); SET_DECLARE(ns, struct nvme_function); -#define NS_USAGE \ -" nvmecontrol ns (create|delete|attach|detach)\n" +#define NS_USAGE \ + "ns (create|delete|attach|detach)\n" /* handles NVME_OPC_NAMESPACE_MANAGEMENT and ATTACHMENT admin cmds */ #define NSCREATE_USAGE \ -" nvmecontrol ns create -s size [-c cap] [-f fmt] [-m mset] [-n nmic] [-p pi] [-l pil] nvmeN\n" + "ns create -s size [-c cap] [-f fmt] [-m mset] [-n nmic] [-p pi] [-l pil] nvmeN\n" #define NSDELETE_USAGE \ -" nvmecontrol ns delete -n nsid nvmeN\n" + "ns delete -n nsid nvmeN\n" #define NSATTACH_USAGE \ -" nvmecontrol ns attach -n nsid [-c ctrlrid] nvmeN \n" + "ns attach -n nsid [-c ctrlrid] nvmeN \n" #define NSDETACH_USAGE \ -" nvmecontrol ns detach -n nsid [-c ctrlrid] nvmeN\n" + "ns detach -n nsid [-c ctrlrid] nvmeN\n" void nscreate(struct nvme_function *nf, int argc, char *argv[]); void nsdelete(struct nvme_function *nf, int argc, char *argv[]); Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/nvmecontrol.c Sun Dec 2 23:13:12 2018 (r341413) @@ -52,7 +52,24 @@ SET_DECLARE(top, struct nvme_function); static void print_usage(const struct nvme_function *f) { - fprintf(stderr, "%s", f->usage); + const char *cp; + char ch; + bool need_prefix = true; + + cp = f->usage; + while (*cp) { + ch = *cp++; + if (need_prefix) { + if (ch != ' ') + fputs(" nvmecontrol ", stderr); + else + fputs(" ", stderr); + } + fputc(ch, stderr); + need_prefix = (ch == '\n'); + } + if (!need_prefix) + fputc('\n', stderr); } static void Modified: head/sbin/nvmecontrol/perftest.c ============================================================================== --- head/sbin/nvmecontrol/perftest.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/perftest.c Sun Dec 2 23:13:12 2018 (r341413) @@ -46,10 +46,10 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define PERFTEST_USAGE \ -" nvmecontrol perftest <-n num_threads> <-o read|write>\n" \ -" <-s size_in_bytes> <-t time_in_seconds>\n" \ -" <-i intr|wait> [-f refthread] [-p]\n" \ -" <namespace id>\n" + "perftest <-n num_threads> <-o read|write>\n" \ + " <-s size_in_bytes> <-t time_in_seconds>\n" \ + " <-i intr|wait> [-f refthread] [-p]\n" \ + " <namespace id>\n" static void print_perftest(struct nvme_io_test *io_test, bool perthread) Modified: head/sbin/nvmecontrol/power.c ============================================================================== --- head/sbin/nvmecontrol/power.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/power.c Sun Dec 2 23:13:12 2018 (r341413) @@ -45,7 +45,7 @@ _Static_assert(sizeof(struct nvme_power_state) == 256 "nvme_power_state size wrong"); #define POWER_USAGE \ -" nvmecontrol power [-l] [-p new-state [-w workload-hint]] <controller id>\n" + "power [-l] [-p new-state [-w workload-hint]] <controller id>\n" static void power_list_one(int i, struct nvme_power_state *nps) Modified: head/sbin/nvmecontrol/reset.c ============================================================================== --- head/sbin/nvmecontrol/reset.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/reset.c Sun Dec 2 23:13:12 2018 (r341413) @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define RESET_USAGE \ -" nvmecontrol reset <controller id>\n" + "reset <controller id>\n" static void reset(struct nvme_function *nf, int argc, char *argv[]) Modified: head/sbin/nvmecontrol/wdc.c ============================================================================== --- head/sbin/nvmecontrol/wdc.c Sun Dec 2 23:12:58 2018 (r341412) +++ head/sbin/nvmecontrol/wdc.c Sun Dec 2 23:13:12 2018 (r341413) @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" #define WDC_USAGE \ -" nvmecontrol wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n" + "wdc (cap-diag)\n" SET_DECLARE(wdc, struct nvme_function); @@ -54,7 +54,7 @@ SET_DECLARE(wdc, struct nvme_function); 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" +#define WDC_CAP_DIAG_USAGE "wdc cap-diag [-o path-template]\n" NVME_COMMAND(wdc, cap-diag, wdc_cap_diag, WDC_CAP_DIAG_USAGE);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812022313.wB2NDCtR037938>