From: Jens Axboe Date: Wed, 30 Dec 2015 15:55:19 +0000 (-0700) Subject: options: make the groups/categories constant X-Git-Tag: fio-2.4~22 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;ds=sidebyside;h=f39159a3e578a88459c80d9efd12529399c12550;p=fio.git options: make the groups/categories constant Signed-off-by: Jens Axboe --- diff --git a/options.c b/options.c index 49d66002..f67969ea 100644 --- a/options.c +++ b/options.c @@ -1045,7 +1045,7 @@ static int gtod_cpu_verify(struct fio_option *o, void *data) /* * Option grouping */ -static struct opt_group fio_opt_groups[] = { +static const struct opt_group fio_opt_groups[] = { { .name = "General", .mask = FIO_OPT_C_GENERAL, @@ -1075,18 +1075,17 @@ static struct opt_group fio_opt_groups[] = { }, }; -static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, +static const struct opt_group *group_from_mask(const struct opt_group *ogs, uint64_t *mask, uint64_t inv_mask) { - struct opt_group *og; int i; if (*mask == inv_mask || !*mask) return NULL; for (i = 0; ogs[i].name; i++) { - og = &ogs[i]; + const struct opt_group *og = &ogs[i]; if (*mask & og->mask) { *mask &= ~(og->mask); @@ -1097,12 +1096,12 @@ static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, return NULL; } -struct opt_group *opt_group_from_mask(uint64_t *mask) +const struct opt_group *opt_group_from_mask(uint64_t *mask) { - return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); + return group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); } -static struct opt_group fio_opt_cat_groups[] = { +static const struct opt_group fio_opt_cat_groups[] = { { .name = "Latency profiling", .mask = FIO_OPT_G_LATPROF, @@ -1201,9 +1200,9 @@ static struct opt_group fio_opt_cat_groups[] = { } }; -struct opt_group *opt_group_cat_from_mask(uint64_t *mask) +const struct opt_group *opt_group_cat_from_mask(uint64_t *mask) { - return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); + return group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); } /* diff --git a/options.h b/options.h index 13b534a9..7bf7205e 100644 --- a/options.h +++ b/options.h @@ -154,8 +154,8 @@ enum opt_category_group { FIO_OPT_G_INVALID = (1ULL << __FIO_OPT_G_NR), }; -extern struct opt_group *opt_group_from_mask(uint64_t *mask); -extern struct opt_group *opt_group_cat_from_mask(uint64_t *mask); +extern const struct opt_group *opt_group_from_mask(uint64_t *mask); +extern const struct opt_group *opt_group_cat_from_mask(uint64_t *mask); extern struct fio_option *fio_option_find(const char *name); extern unsigned int fio_get_kb_base(void *);