Date: Mon, 12 Aug 2019 17:49:07 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350915 - stable/12/sbin/nvmecontrol Message-ID: <201908121749.x7CHn72p022699@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Aug 12 17:49:06 2019 New Revision: 350915 URL: https://svnweb.freebsd.org/changeset/base/350915 Log: MFC r341658 (by imp): Const poison the command interface Make the pointers we pass into the commands const, also make the linker set mirrors const. Modified: stable/12/sbin/nvmecontrol/devlist.c stable/12/sbin/nvmecontrol/firmware.c stable/12/sbin/nvmecontrol/format.c stable/12/sbin/nvmecontrol/identify.c stable/12/sbin/nvmecontrol/logpage.c stable/12/sbin/nvmecontrol/ns.c stable/12/sbin/nvmecontrol/nvmecontrol.c stable/12/sbin/nvmecontrol/nvmecontrol.h stable/12/sbin/nvmecontrol/perftest.c stable/12/sbin/nvmecontrol/power.c stable/12/sbin/nvmecontrol/reset.c stable/12/sbin/nvmecontrol/wdc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/nvmecontrol/devlist.c ============================================================================== --- stable/12/sbin/nvmecontrol/devlist.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/devlist.c Mon Aug 12 17:49:06 2019 (r350915) @@ -60,7 +60,7 @@ ns_get_sector_size(struct nvme_namespace_data *nsdata) } static void -devlist(struct nvme_function *nf, int argc, char *argv[]) +devlist(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cdata; struct nvme_namespace_data nsdata; Modified: stable/12/sbin/nvmecontrol/firmware.c ============================================================================== --- stable/12/sbin/nvmecontrol/firmware.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/firmware.c Mon Aug 12 17:49:06 2019 (r350915) @@ -174,7 +174,7 @@ activate_firmware(int fd, int slot, int activate_actio } static void -firmware(struct nvme_function *nf, int argc, char *argv[]) +firmware(const struct nvme_function *nf, int argc, char *argv[]) { int fd = -1, slot = 0; int a_flag, s_flag, f_flag; Modified: stable/12/sbin/nvmecontrol/format.c ============================================================================== --- stable/12/sbin/nvmecontrol/format.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/format.c Mon Aug 12 17:49:06 2019 (r350915) @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); "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[]) +format(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cd; struct nvme_namespace_data nsd; Modified: stable/12/sbin/nvmecontrol/identify.c ============================================================================== --- stable/12/sbin/nvmecontrol/identify.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/identify.c Mon Aug 12 17:49:06 2019 (r350915) @@ -160,7 +160,7 @@ print_namespace(struct nvme_namespace_data *nsdata) } static void -identify_ctrlr(struct nvme_function *nf, int argc, char *argv[]) +identify_ctrlr(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cdata; int ch, fd, hexflag = 0, hexlength; @@ -207,7 +207,7 @@ identify_ctrlr(struct nvme_function *nf, int argc, cha } static void -identify_ns(struct nvme_function *nf,int argc, char *argv[]) +identify_ns(const struct nvme_function *nf,int argc, char *argv[]) { struct nvme_namespace_data nsdata; char path[64]; @@ -271,7 +271,7 @@ identify_ns(struct nvme_function *nf,int argc, char *a } static void -identify(struct nvme_function *nf, int argc, char *argv[]) +identify(const struct nvme_function *nf, int argc, char *argv[]) { char *target; Modified: stable/12/sbin/nvmecontrol/logpage.c ============================================================================== --- stable/12/sbin/nvmecontrol/logpage.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/logpage.c Mon Aug 12 17:49:06 2019 (r350915) @@ -326,7 +326,7 @@ NVME_LOGPAGE(fw, static void logpage_help(void) { - struct logpage_function **f; + const struct logpage_function * const *f; const char *v; fprintf(stderr, "\n"); @@ -341,7 +341,7 @@ logpage_help(void) } static void -logpage(struct nvme_function *nf, int argc, char *argv[]) +logpage(const struct nvme_function *nf, int argc, char *argv[]) { int fd; int log_page = 0, pageflag = false; @@ -352,7 +352,7 @@ logpage(struct nvme_function *nf, int argc, char *argv uint32_t nsid, size; void *buf; const char *vendor = NULL; - struct logpage_function **f; + const struct logpage_function * const *f; struct nvme_controller_data cdata; print_fn_t print_fn; uint8_t ns_smart; Modified: stable/12/sbin/nvmecontrol/ns.c ============================================================================== --- stable/12/sbin/nvmecontrol/ns.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/ns.c Mon Aug 12 17:49:06 2019 (r350915) @@ -60,10 +60,10 @@ NVME_CMD_DECLARE(ns, struct nvme_function); #define NSDETACH_USAGE \ "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[]); -void nsattach(struct nvme_function *nf, int argc, char *argv[]); -void nsdetach(struct nvme_function *nf, int argc, char *argv[]); +static void nscreate(const struct nvme_function *nf, int argc, char *argv[]); +static void nsdelete(const struct nvme_function *nf, int argc, char *argv[]); +static void nsattach(const struct nvme_function *nf, int argc, char *argv[]); +static void nsdetach(const struct nvme_function *nf, int argc, char *argv[]); NVME_COMMAND(ns, create, nscreate, NSCREATE_USAGE); NVME_COMMAND(ns, delete, nsdelete, NSDELETE_USAGE); @@ -109,8 +109,8 @@ get_res_str(uint16_t res) * 0x16 = Namespace ID unavailable (number namespaces exceeded) * 0xb = Thin Provisioning Not supported */ -void -nscreate(struct nvme_function *nf, int argc, char *argv[]) +static void +nscreate(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -204,8 +204,8 @@ nscreate(struct nvme_function *nf, int argc, char *arg exit(0); } -void -nsdelete(struct nvme_function *nf, int argc, char *argv[]) +static void +nsdelete(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -271,8 +271,8 @@ nsdelete(struct nvme_function *nf, int argc, char *arg * * 0x2 Invalid Field can occur if ctrlrid d.n.e in system. */ -void -nsattach(struct nvme_function *nf, int argc, char *argv[]) +static void +nsattach(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -350,8 +350,8 @@ nsattach(struct nvme_function *nf, int argc, char *arg exit(0); } -void -nsdetach(struct nvme_function *nf, int argc, char *argv[]) +static void +nsdetach(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_pt_command pt; struct nvme_controller_data cd; @@ -437,7 +437,7 @@ nsdetach(struct nvme_function *nf, int argc, char *arg } static void -ns(struct nvme_function *nf __unused, int argc, char *argv[]) +ns(const struct nvme_function *nf __unused, int argc, char *argv[]) { DISPATCH(argc, argv, ns); Modified: stable/12/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- stable/12/sbin/nvmecontrol/nvmecontrol.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/nvmecontrol.c Mon Aug 12 17:49:06 2019 (r350915) @@ -75,7 +75,7 @@ print_usage(const struct nvme_function *f) } static void -gen_usage_set(struct nvme_function **f, struct nvme_function **flimit) +gen_usage_set(const struct nvme_function * const *f, const struct nvme_function * const *flimit) { fprintf(stderr, "usage:\n"); @@ -96,10 +96,10 @@ usage(const struct nvme_function *f) } void -dispatch_set(int argc, char *argv[], struct nvme_function **tbl, - struct nvme_function **tbl_limit) +dispatch_set(int argc, char *argv[], const struct nvme_function * const *tbl, + const struct nvme_function * const *tbl_limit) { - struct nvme_function **f = tbl; + const struct nvme_function * const *f = tbl; if (argv[1] == NULL) { gen_usage_set(tbl, tbl_limit); Modified: stable/12/sbin/nvmecontrol/nvmecontrol.h ============================================================================== --- stable/12/sbin/nvmecontrol/nvmecontrol.h Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/nvmecontrol.h Mon Aug 12 17:49:06 2019 (r350915) @@ -35,7 +35,7 @@ #include <dev/nvme/nvme.h> struct nvme_function; -typedef void (*nvme_fn_t)(struct nvme_function *nf, int argc, char *argv[]); +typedef void (*nvme_fn_t)(const struct nvme_function *nf, int argc, char *argv[]); struct nvme_function { const char *name; @@ -96,8 +96,8 @@ struct set_concat { void set_concat_add(struct set_concat *m, void *begin, void *end); #define SET_CONCAT_DEF(set, t) \ static struct set_concat set ## _concat; \ -static inline t **set ## _begin() { return ((t **)set ## _concat.begin); } \ -static inline t **set ## _limit() { return ((t **)set ## _concat.limit); } \ +static inline const t * const *set ## _begin() { return ((const t * const *)set ## _concat.begin); } \ +static inline const t * const *set ## _limit() { return ((const t * const *)set ## _concat.limit); } \ void add_to_ ## set(t **b, t **e) \ { \ set_concat_add(&set ## _concat, b, e); \ @@ -120,11 +120,13 @@ void read_logpage(int fd, uint8_t log_page, uint32_t n void print_temp(uint16_t t); void usage(const struct nvme_function *f); -void dispatch_set(int argc, char *argv[], struct nvme_function **tbl, - struct nvme_function **tbl_limit); +void dispatch_set(int argc, char *argv[], const struct nvme_function * const *tbl, + const struct nvme_function * const *tbl_limit); -#define DISPATCH(argc, argv, set) \ - dispatch_set(argc, argv, NVME_CMD_BEGIN(set), NVME_CMD_LIMIT(set)) +#define DISPATCH(argc, argv, set) \ + dispatch_set(argc, argv, \ + (const struct nvme_function * const *)NVME_CMD_BEGIN(set), \ + (const struct nvme_function * const *)NVME_CMD_LIMIT(set)) \ /* Utility Routines */ /* Modified: stable/12/sbin/nvmecontrol/perftest.c ============================================================================== --- stable/12/sbin/nvmecontrol/perftest.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/perftest.c Mon Aug 12 17:49:06 2019 (r350915) @@ -75,7 +75,7 @@ print_perftest(struct nvme_io_test *io_test, bool pert } static void -perftest(struct nvme_function *nf, int argc, char *argv[]) +perftest(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_io_test io_test; int fd; Modified: stable/12/sbin/nvmecontrol/power.c ============================================================================== --- stable/12/sbin/nvmecontrol/power.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/power.c Mon Aug 12 17:49:06 2019 (r350915) @@ -129,7 +129,7 @@ power_show(int fd) } static void -power(struct nvme_function *nf, int argc, char *argv[]) +power(const struct nvme_function *nf, int argc, char *argv[]) { struct nvme_controller_data cdata; int ch, listflag = 0, powerflag = 0, power_val = 0, fd; Modified: stable/12/sbin/nvmecontrol/reset.c ============================================================================== --- stable/12/sbin/nvmecontrol/reset.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/reset.c Mon Aug 12 17:49:06 2019 (r350915) @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); "reset <controller id>\n" static void -reset(struct nvme_function *nf, int argc, char *argv[]) +reset(const struct nvme_function *nf, int argc, char *argv[]) { int ch, fd; Modified: stable/12/sbin/nvmecontrol/wdc.c ============================================================================== --- stable/12/sbin/nvmecontrol/wdc.c Mon Aug 12 17:48:14 2019 (r350914) +++ stable/12/sbin/nvmecontrol/wdc.c Mon Aug 12 17:49:06 2019 (r350915) @@ -52,7 +52,7 @@ NVME_CMD_DECLARE(wdc, struct nvme_function); #define WDC_NVME_CAP_DIAG_OPCODE 0xe6 #define WDC_NVME_CAP_DIAG_CMD 0x0000 -static void wdc_cap_diag(struct nvme_function *nf, int argc, char *argv[]); +static void wdc_cap_diag(const struct nvme_function *nf, int argc, char *argv[]); #define WDC_CAP_DIAG_USAGE "wdc cap-diag [-o path-template]\n" @@ -154,7 +154,7 @@ wdc_do_dump(int fd, char *tmpl, const char *suffix, ui } static void -wdc_cap_diag(struct nvme_function *nf, int argc, char *argv[]) +wdc_cap_diag(const struct nvme_function *nf, int argc, char *argv[]) { char path_tmpl[MAXPATHLEN]; int ch, fd; @@ -183,7 +183,7 @@ wdc_cap_diag(struct nvme_function *nf, int argc, char } static void -wdc(struct nvme_function *nf __unused, int argc, char *argv[]) +wdc(const 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?201908121749.x7CHn72p022699>