This patch does not modify any functionality but makes the option
parsing code slightly easier to read by marking arguments that are
not modified explicitly as 'const'. A new function has been added,
find_option_c(), that behaves identically to find_option(). Only
the function signature differs between these two functions.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
-static int rw_verify(struct fio_option *o, void *data)
+static int rw_verify(const struct fio_option *o, void *data)
{
struct thread_data *td = cb_data_to_td(data);
{
struct thread_data *td = cb_data_to_td(data);
-static int gtod_cpu_verify(struct fio_option *o, void *data)
+static int gtod_cpu_verify(const struct fio_option *o, void *data)
{
#ifndef FIO_HAVE_CPU_AFFINITY
struct thread_data *td = cb_data_to_td(data);
{
#ifndef FIO_HAVE_CPU_AFFINITY
struct thread_data *td = cb_data_to_td(data);
opts_copy = dup_and_sub_options(opts, num_opts);
for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
opts_copy = dup_and_sub_options(opts, num_opts);
for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
+ const struct fio_option *o;
int newret = parse_option(opts_copy[i], opts[i], fio_options,
&o, &td->o, &td->opt_list);
int newret = parse_option(opts_copy[i], opts[i], fio_options,
&o, &td->o, &td->opt_list);
opts = opts_copy;
}
for (i = 0; i < num_opts; i++) {
opts = opts_copy;
}
for (i = 0; i < num_opts; i++) {
- struct fio_option *o = NULL;
+ const struct fio_option *o = NULL;
int newret = 1;
if (!opts_copy[i])
int newret = 1;
if (!opts_copy[i])
ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
if (!ret) {
ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
if (!ret) {
+ const struct fio_option *o;
- o = find_option(fio_options, opt);
+ o = find_option_c(fio_options, opt);
if (o)
fio_option_mark_set(&td->o, o);
}
if (o)
fio_option_mark_set(&td->o, o);
}
-int add_option(struct fio_option *o)
+int add_option(const struct fio_option *o)
{
struct fio_option *__o;
int opt_index = 0;
{
struct fio_option *__o;
int opt_index = 0;
-void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
+void fio_option_mark_set(struct thread_options *o, const struct fio_option *opt)
{
unsigned int opt_off, index, offset;
{
unsigned int opt_off, index, offset;
#include "parse.h"
#include "lib/types.h"
#include "parse.h"
#include "lib/types.h"
-int add_option(struct fio_option *);
+int add_option(const struct fio_option *);
void invalidate_profile_options(const char *);
extern char *exec_profile;
void invalidate_profile_options(const char *);
extern char *exec_profile;
-extern void fio_option_mark_set(struct thread_options *, struct fio_option *);
+extern void fio_option_mark_set(struct thread_options *,
+ const struct fio_option *);
-static inline bool o_match(struct fio_option *o, const char *opt)
+static inline bool o_match(const struct fio_option *o, const char *opt)
{
if (!strcmp(o->name, opt))
return true;
{
if (!strcmp(o->name, opt))
return true;
}
extern struct fio_option *find_option(struct fio_option *, const char *);
}
extern struct fio_option *find_option(struct fio_option *, const char *);
+extern const struct fio_option *
+find_option_c(const struct fio_option *, const char *);
extern struct fio_option *fio_option_find(const char *);
extern unsigned int fio_get_kb_base(void *);
extern struct fio_option *fio_option_find(const char *);
extern unsigned int fio_get_kb_base(void *);
-static struct fio_option *__fio_options;
+static const struct fio_option *__fio_options;
static int vp_cmp(const void *p1, const void *p2)
{
static int vp_cmp(const void *p1, const void *p2)
{
return strlen(vp2->ival) - strlen(vp1->ival);
}
return strlen(vp2->ival) - strlen(vp1->ival);
}
-static void posval_sort(struct fio_option *o, struct value_pair *vpmap)
+static void posval_sort(const struct fio_option *o, struct value_pair *vpmap)
{
const struct value_pair *vp;
int entries;
{
const struct value_pair *vp;
int entries;
qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp);
}
qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp);
}
-static void show_option_range(struct fio_option *o,
+static void show_option_range(const struct fio_option *o,
size_t (*logger)(const char *format, ...))
{
if (o->type == FIO_OPT_FLOAT_LIST) {
size_t (*logger)(const char *format, ...))
{
if (o->type == FIO_OPT_FLOAT_LIST) {
-static void show_option_values(struct fio_option *o)
+static void show_option_values(const struct fio_option *o)
-static void show_option_help(struct fio_option *o, int is_err)
+static void show_option_help(const struct fio_option *o, int is_err)
{
const char *typehelp[] = {
"invalid",
{
const char *typehelp[] = {
"invalid",
*ptr = (val); \
} while (0)
*ptr = (val); \
} while (0)
-static const char *opt_type_name(struct fio_option *o)
+static const char *opt_type_name(const struct fio_option *o)
{
compiletime_assert(ARRAY_SIZE(opt_type_names) - 1 == FIO_OPT_UNSUPPORTED,
"opt_type_names[] index");
{
compiletime_assert(ARRAY_SIZE(opt_type_names) - 1 == FIO_OPT_UNSUPPORTED,
"opt_type_names[] index");
-static int __handle_option(struct fio_option *o, const char *ptr, void *data,
- int first, int more, int curr)
+static int __handle_option(const struct fio_option *o, const char *ptr,
+ void *data, int first, int more, int curr)
{
int il=0, *ilp;
fio_fp64_t *flp;
{
int il=0, *ilp;
fio_fp64_t *flp;
-static int handle_option(struct fio_option *o, const char *__ptr, void *data)
+static int handle_option(const struct fio_option *o, const char *__ptr,
+ void *data)
{
char *o_ptr, *ptr, *ptr2;
int ret, done;
{
char *o_ptr, *ptr, *ptr2;
int ret, done;
+const struct fio_option *
+find_option_c(const struct fio_option *options, const char *opt)
+{
+ return find_option((struct fio_option *)options, opt);
+}
-static struct fio_option *get_option(char *opt,
- struct fio_option *options, char **post)
+static const struct fio_option *
+get_option(char *opt, const struct fio_option *options, char **post)
+ const struct fio_option *o;
char *ret;
ret = strchr(opt, '=');
char *ret;
ret = strchr(opt, '=');
ret = opt;
(*post)++;
strip_blank_end(ret);
ret = opt;
(*post)++;
strip_blank_end(ret);
- o = find_option(options, ret);
+ o = find_option_c(options, ret);
- o = find_option(options, opt);
+ o = find_option_c(options, opt);
static int opt_cmp(const void *p1, const void *p2)
{
static int opt_cmp(const void *p1, const void *p2)
{
+ const struct fio_option *o;
char *s, *foo;
int prio1, prio2;
char *s, *foo;
int prio1, prio2;
-void sort_options(char **opts, struct fio_option *options, int num_opts)
+void sort_options(char **opts, const struct fio_option *options, int num_opts)
{
__fio_options = options;
qsort(opts, num_opts, sizeof(char *), opt_cmp);
__fio_options = NULL;
}
{
__fio_options = options;
qsort(opts, num_opts, sizeof(char *), opt_cmp);
__fio_options = NULL;
}
-static void add_to_dump_list(struct fio_option *o, struct flist_head *dump_list,
- const char *post)
+static void add_to_dump_list(const struct fio_option *o,
+ struct flist_head *dump_list, const char *post)
{
struct print_option *p;
{
struct print_option *p;
}
int parse_cmd_option(const char *opt, const char *val,
}
int parse_cmd_option(const char *opt, const char *val,
- struct fio_option *options, void *data,
+ const struct fio_option *options, void *data,
struct flist_head *dump_list)
{
struct flist_head *dump_list)
{
+ const struct fio_option *o;
- o = find_option(options, opt);
+ o = find_option_c(options, opt);
if (!o) {
log_err("Bad option <%s>\n", opt);
return 1;
if (!o) {
log_err("Bad option <%s>\n", opt);
return 1;
-int parse_option(char *opt, const char *input,
- struct fio_option *options, struct fio_option **o, void *data,
+int parse_option(char *opt, const char *input, const struct fio_option *options,
+ const struct fio_option **o, void *data,
struct flist_head *dump_list)
{
char *post;
struct flist_head *dump_list)
{
char *post;
return distance <= len;
}
return distance <= len;
}
-static struct fio_option *find_child(struct fio_option *options,
- struct fio_option *o)
+static const struct fio_option *find_child(const struct fio_option *options,
+ const struct fio_option *o)
- struct fio_option *__o;
+ const struct fio_option *__o;
for (__o = options + 1; __o->name; __o++)
if (__o->parent && !strcmp(__o->parent, o->name))
for (__o = options + 1; __o->name; __o++)
if (__o->parent && !strcmp(__o->parent, o->name))
-static void __print_option(struct fio_option *o, struct fio_option *org,
+static void __print_option(const struct fio_option *o,
+ const struct fio_option *org,
int level)
{
char name[256], *p;
int level)
{
char name[256], *p;
log_info("%-24s: %s\n", name, o->help);
}
log_info("%-24s: %s\n", name, o->help);
}
-static void print_option(struct fio_option *o)
+static void print_option(const struct fio_option *o)
- struct fio_option *parent;
- struct fio_option *__o;
+ const struct fio_option *parent;
+ const struct fio_option *__o;
unsigned int printed;
unsigned int level;
unsigned int printed;
unsigned int level;
-int show_cmd_help(struct fio_option *options, const char *name)
+int show_cmd_help(const struct fio_option *options, const char *name)
- struct fio_option *o, *closest;
+ const struct fio_option *o, *closest;
unsigned int best_dist = -1U;
int found = 0;
int show_all = 0;
unsigned int best_dist = -1U;
int found = 0;
int show_all = 0;
/*
* Handle parsing of default parameters.
*/
/*
* Handle parsing of default parameters.
*/
-void fill_default_options(void *data, struct fio_option *options)
+void fill_default_options(void *data, const struct fio_option *options)
+ const struct fio_option *o;
dprint(FD_PARSE, "filling default options\n");
dprint(FD_PARSE, "filling default options\n");
-void options_mem_dupe(struct fio_option *options, void *data)
+void options_mem_dupe(const struct fio_option *options, void *data)
+ const struct fio_option *o;
char **ptr;
dprint(FD_PARSE, "dup options\n");
char **ptr;
dprint(FD_PARSE, "dup options\n");
-void options_free(struct fio_option *options, void *data)
+void options_free(const struct fio_option *options, void *data)
+ const struct fio_option *o;
char **ptr;
dprint(FD_PARSE, "free options\n");
char **ptr;
dprint(FD_PARSE, "free options\n");
int hide_on_set; /* hide on set, not on unset */
const char *inverse; /* if set, apply opposite action to this option */
struct fio_option *inv_opt; /* cached lookup */
int hide_on_set; /* hide on set, not on unset */
const char *inverse; /* if set, apply opposite action to this option */
struct fio_option *inv_opt; /* cached lookup */
- int (*verify)(struct fio_option *, void *);
+ int (*verify)(const struct fio_option *, void *);
const char *prof_name; /* only valid for specific profile */
void *prof_opts;
uint64_t category; /* what type of option */
const char *prof_name; /* only valid for specific profile */
void *prof_opts;
uint64_t category; /* what type of option */
-extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *, struct flist_head *);
-extern void sort_options(char **, struct fio_option *, int);
-extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *, struct flist_head *);
-extern int show_cmd_help(struct fio_option *, const char *);
-extern void fill_default_options(void *, struct fio_option *);
+extern int parse_option(char *, const char *, const struct fio_option *,
+ const struct fio_option **, void *,
+ struct flist_head *);
+extern void sort_options(char **, const struct fio_option *, int);
+extern int parse_cmd_option(const char *t, const char *l,
+ const struct fio_option *, void *,
+ struct flist_head *);
+extern int show_cmd_help(const struct fio_option *, const char *);
+extern void fill_default_options(void *, const struct fio_option *);
extern void options_init(struct fio_option *);
extern void options_init(struct fio_option *);
-extern void options_mem_dupe(struct fio_option *, void *);
-extern void options_free(struct fio_option *, void *);
+extern void options_mem_dupe(const struct fio_option *, void *);
+extern void options_free(const struct fio_option *, void *);
extern void strip_blank_front(char **);
extern void strip_blank_end(char *);
extern void strip_blank_front(char **);
extern void strip_blank_end(char *);
typedef int (fio_opt_int_fn)(void *, int *);
struct thread_options;
typedef int (fio_opt_int_fn)(void *, int *);
struct thread_options;
-static inline void *td_var(void *to, struct fio_option *o, unsigned int offset)
+static inline void *td_var(void *to, const struct fio_option *o,
+ unsigned int offset)