Index: head/sbin/nvmecontrol/devlist.c =================================================================== --- head/sbin/nvmecontrol/devlist.c +++ head/sbin/nvmecontrol/devlist.c @@ -60,7 +60,7 @@ } 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; Index: head/sbin/nvmecontrol/firmware.c =================================================================== --- head/sbin/nvmecontrol/firmware.c +++ head/sbin/nvmecontrol/firmware.c @@ -174,7 +174,7 @@ } 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; Index: head/sbin/nvmecontrol/format.c =================================================================== --- head/sbin/nvmecontrol/format.c +++ head/sbin/nvmecontrol/format.c @@ -47,7 +47,7 @@ "format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] \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; Index: head/sbin/nvmecontrol/identify.c =================================================================== --- head/sbin/nvmecontrol/identify.c +++ head/sbin/nvmecontrol/identify.c @@ -150,7 +150,7 @@ } 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; @@ -197,7 +197,7 @@ } 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]; @@ -261,7 +261,7 @@ } static void -identify(struct nvme_function *nf, int argc, char *argv[]) +identify(const struct nvme_function *nf, int argc, char *argv[]) { char *target; Index: head/sbin/nvmecontrol/logpage.c =================================================================== --- head/sbin/nvmecontrol/logpage.c +++ head/sbin/nvmecontrol/logpage.c @@ -326,7 +326,7 @@ 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 @@ } 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 @@ 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; Index: head/sbin/nvmecontrol/ns.c =================================================================== --- head/sbin/nvmecontrol/ns.c +++ head/sbin/nvmecontrol/ns.c @@ -60,10 +60,10 @@ #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 @@ * 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 @@ 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 @@ * * 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 @@ 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 @@ } 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); Index: head/sbin/nvmecontrol/nvmecontrol.h =================================================================== --- head/sbin/nvmecontrol/nvmecontrol.h +++ head/sbin/nvmecontrol/nvmecontrol.h @@ -35,7 +35,7 @@ #include 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 @@ 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 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 */ /* Index: head/sbin/nvmecontrol/nvmecontrol.c =================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c +++ head/sbin/nvmecontrol/nvmecontrol.c @@ -75,7 +75,7 @@ } 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 @@ } 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); Index: head/sbin/nvmecontrol/perftest.c =================================================================== --- head/sbin/nvmecontrol/perftest.c +++ head/sbin/nvmecontrol/perftest.c @@ -75,7 +75,7 @@ } 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; Index: head/sbin/nvmecontrol/power.c =================================================================== --- head/sbin/nvmecontrol/power.c +++ head/sbin/nvmecontrol/power.c @@ -129,7 +129,7 @@ } 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; Index: head/sbin/nvmecontrol/reset.c =================================================================== --- head/sbin/nvmecontrol/reset.c +++ head/sbin/nvmecontrol/reset.c @@ -45,7 +45,7 @@ "reset \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; Index: head/sbin/nvmecontrol/wdc.c =================================================================== --- head/sbin/nvmecontrol/wdc.c +++ head/sbin/nvmecontrol/wdc.c @@ -52,7 +52,7 @@ #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 @@ } 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 @@ } 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);