options: make the groups/categories constant
authorJens Axboe <axboe@fb.com>
Wed, 30 Dec 2015 15:55:19 +0000 (08:55 -0700)
committerJens Axboe <axboe@fb.com>
Wed, 30 Dec 2015 15:55:19 +0000 (08:55 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
options.c
options.h

index 49d66002602de97baf7899d643cb755c6ec1b204..f67969eace72c7301b8c872ce16d643d68c5226b 100644 (file)
--- 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);
 }
 
 /*
index 13b534a9d9cc6cbbea85a741879d1913dbea0a91..7bf7205e9963d3b297436013d0664bddb13e00c0 100644 (file)
--- 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 *);