Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/nvmectl use setprogname()/getprogname(), do not hardcod...
details: https://anonhg.NetBSD.org/src/rev/5f96c0b8aa00
branches: trunk
changeset: 360584:5f96c0b8aa00
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sat Mar 17 11:07:26 2018 +0000
description:
use setprogname()/getprogname(), do not hardcode the prognam name in fixed
strings
diffstat:
sbin/nvmectl/devlist.c | 6 +++---
sbin/nvmectl/identify.c | 6 +++---
sbin/nvmectl/logpage.c | 6 +++---
sbin/nvmectl/nvmectl.c | 15 ++++++++-------
sbin/nvmectl/nvmectl.h | 20 ++++++++++----------
sbin/nvmectl/perftest.c | 6 +++---
sbin/nvmectl/power.c | 6 +++---
sbin/nvmectl/reset.c | 6 +++---
sbin/nvmectl/wdc.c | 22 +++++++++++-----------
9 files changed, 47 insertions(+), 46 deletions(-)
diffs (truncated from 353 to 300 lines):
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/devlist.c
--- a/sbin/nvmectl/devlist.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/devlist.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devlist.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: devlist.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 260381 2014-01-06 23:48:47Z jimharris $");
#endif
@@ -52,7 +52,7 @@
devlist_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, DEVLIST_USAGE);
+ fprintf(stderr, "\t%s " DEVLIST_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/identify.c
--- a/sbin/nvmectl/identify.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/identify.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: identify.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: identify.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 253476 2013-07-19 21:40:57Z jimharris $");
#endif
@@ -170,7 +170,7 @@
identify_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, IDENTIFY_USAGE);
+ fprintf(stderr, "\t%s " IDENTIFY_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/logpage.c
--- a/sbin/nvmectl/logpage.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/logpage.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: logpage.c,v 1.4 2017/04/29 00:06:40 nonaka Exp $ */
+/* $NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2013 EMC Corp.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: logpage.c,v 1.4 2017/04/29 00:06:40 nonaka Exp $");
+__RCSID("$NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/logpage.c 314230 2017-02-25 00:09:16Z imp $");
#endif
@@ -899,7 +899,7 @@
logpage_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, LOGPAGE_USAGE);
+ fprintf(stderr, "\t%s " LOGPAGE_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/nvmectl.c
--- a/sbin/nvmectl/nvmectl.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/nvmectl.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmectl.c,v 1.4 2017/05/03 01:37:16 christos Exp $ */
+/* $NetBSD: nvmectl.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: nvmectl.c,v 1.4 2017/05/03 01:37:16 christos Exp $");
+__RCSID("$NetBSD: nvmectl.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/nvmecontrol.c 314229 2017-02-25 00:09:12Z imp $");
#endif
@@ -52,7 +52,7 @@
#include "nvmectl.h"
-static struct nvme_function funcs[] = {
+static const struct nvme_function funcs[] = {
{"devlist", devlist, DEVLIST_USAGE},
{"identify", identify, IDENTIFY_USAGE},
#ifdef PERFTEST_USAGE
@@ -71,21 +71,21 @@
};
static __dead void
-gen_usage(struct nvme_function *f)
+gen_usage(const struct nvme_function *f)
{
fprintf(stderr, "usage:\n");
while (f->name != NULL) {
- fprintf(stderr, "%s", f->usage);
+ fprintf(stderr, "\t%s %s", getprogname(), f->usage);
f++;
}
exit(1);
}
__dead void
-dispatch(int argc, char *argv[], struct nvme_function *tbl)
+dispatch(int argc, char *argv[], const struct nvme_function *tbl)
{
- struct nvme_function *f = tbl;
+ const struct nvme_function *f = tbl;
if (argv[1] == NULL)
gen_usage(tbl);
@@ -280,6 +280,7 @@
int
main(int argc, char *argv[])
{
+ setprogname(argv[0]);
if (argc < 2)
gen_usage(funcs);
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/nvmectl.h
--- a/sbin/nvmectl/nvmectl.h Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/nvmectl.h Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmectl.h,v 1.4 2017/05/03 01:37:16 christos Exp $ */
+/* $NetBSD: nvmectl.h,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -48,14 +48,14 @@
#define NVME_NS_PREFIX "ns"
#define DEVLIST_USAGE \
-" nvmectl devlist\n"
+"devlist\n"
#define IDENTIFY_USAGE \
-" nvmectl identify [-x [-v]] <controller id|namespace id>\n"
+"identify [-x [-v]] <controller id|namespace id>\n"
#if 0
#define PERFTEST_USAGE \
-" nvmectl perftest <-n num_threads> <-o read|write>\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"
@@ -63,23 +63,23 @@
#if 0
#define RESET_USAGE \
-" nvmectl reset <controller id>\n"
+"reset <controller id>\n"
#endif
#define LOGPAGE_USAGE \
-" nvmectl logpage <-p page_id> [-b] [-v vendor] [-x] " \
+"logpage <-p page_id> [-b] [-v vendor] [-x] " \
"<controller id|namespace id>\n"
#if 0
#define FIRMWARE_USAGE \
-" nvmectl firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
+"firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
#endif
#define POWER_USAGE \
-" nvmectl power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
+"power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
#define WDC_USAGE \
-" nvmecontrol wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
+"wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
void devlist(int, char *[]) __dead;
void identify(int, char *[]) __dead;
@@ -102,7 +102,7 @@
void read_namespace_data(int, int, struct nvm_identify_namespace *);
void print_hex(void *, uint32_t);
void read_logpage(int, uint8_t, int, void *, uint32_t);
-__dead void dispatch(int argc, char *argv[], struct nvme_function *f);
+__dead void dispatch(int argc, char *argv[], const struct nvme_function *f);
void nvme_strvis(uint8_t *, int, const uint8_t *, int);
#endif /* __NVMECTL_H__ */
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/perftest.c
--- a/sbin/nvmectl/perftest.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/perftest.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perftest.c,v 1.2 2016/07/14 10:02:43 nonaka Exp $ */
+/* $NetBSD: perftest.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: perftest.c,v 1.2 2016/07/14 10:02:43 nonaka Exp $");
+__RCSID("$NetBSD: perftest.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/perftest.c 257531 2013-11-01 22:05:29Z jimharris $");
#endif
@@ -78,7 +78,7 @@
perftest_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, PERFTEST_USAGE);
+ fprintf(stderr, "\t%s" PERFTEST_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/power.c
--- a/sbin/nvmectl/power.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/power.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: power.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: power.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2016 Netflix, Inc
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: power.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: power.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/power.c 296672 2016-03-11 17:25:18Z dim $");
#endif
@@ -52,7 +52,7 @@
power_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, POWER_USAGE);
+ fprintf(stderr, "\t%s " POWER_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/reset.c
--- a/sbin/nvmectl/reset.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/reset.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: reset.c,v 1.1 2016/06/04 16:29:35 nonaka Exp $ */
+/* $NetBSD: reset.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: reset.c,v 1.1 2016/06/04 16:29:35 nonaka Exp $");
+__RCSID("$NetBSD: reset.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/reset.c 253109 2013-07-09 21:14:15Z jimharris $");
#endif
@@ -51,7 +51,7 @@
reset_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, RESET_USAGE);
+ fprintf(stderr, "\t%s " RESET_USAGE, getprogname());
exit(1);
}
diff -r 4109f4b3872b -r 5f96c0b8aa00 sbin/nvmectl/wdc.c
--- a/sbin/nvmectl/wdc.c Sat Mar 17 11:06:48 2018 +0000
+++ b/sbin/nvmectl/wdc.c Sat Mar 17 11:07:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.1 2017/04/29 00:08:46 nonaka Exp $ */
+/* $NetBSD: wdc.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
Home |
Main Index |
Thread Index |
Old Index