parse: cleanup difference between profile and normal options
authorJens Axboe <axboe@fb.com>
Tue, 11 Feb 2014 22:44:50 +0000 (15:44 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 11 Feb 2014 22:44:50 +0000 (15:44 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
goptions.c
options.c
parse.c
parse.h

index 33183682d97f7eb3f2ab0887ffe6cea575245e24..21d642771be3ad881b35bd23aec07c2a146f4b8e 100644 (file)
@@ -874,7 +874,7 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                struct gopt_str_val *g;
 
                if (o->off1)
                struct gopt_str_val *g;
 
                if (o->off1)
-                       ullp = td_var(to, o->off1);
+                       ullp = td_var(to, o, o->off1);
 
                g = container_of(gopt, struct gopt_str_val, gopt);
                if (ullp)
 
                g = container_of(gopt, struct gopt_str_val, gopt);
                if (ullp)
@@ -885,12 +885,8 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                unsigned long long *ullp = NULL;
                struct gopt_int *i;
 
                unsigned long long *ullp = NULL;
                struct gopt_int *i;
 
-               if (o->off1) {
-                       if (o->prof_opts)
-                               ullp = td_var(o->prof_opts, o->off1);
-                       else
-                               ullp = td_var(to, o->off1);
-               }
+               if (o->off1)
+                       ullp = td_var(to, o, o->off1);
 
                i = container_of(gopt, struct gopt_int, gopt);
                if (ullp)
 
                i = container_of(gopt, struct gopt_int, gopt);
                if (ullp)
@@ -902,12 +898,8 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                        unsigned int *ip = NULL;
                        struct gopt_combo *c;
 
                        unsigned int *ip = NULL;
                        struct gopt_combo *c;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        c = container_of(gopt, struct gopt_combo, gopt);
                        if (ip)
 
                        c = container_of(gopt, struct gopt_combo, gopt);
                        if (ip)
@@ -916,12 +908,8 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                        unsigned int *ip = NULL;
                        struct gopt_int *i;
 
                        unsigned int *ip = NULL;
                        struct gopt_int *i;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        i = container_of(gopt, struct gopt_int, gopt);
                        if (ip)
 
                        i = container_of(gopt, struct gopt_int, gopt);
                        if (ip)
@@ -933,12 +921,8 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                unsigned int *ip = NULL;
                struct gopt_bool *b;
 
                unsigned int *ip = NULL;
                struct gopt_bool *b;
 
-               if (o->off1) {
-                       if (o->prof_opts)
-                               ip = td_var(o->prof_opts, o->off1);
-                       else
-                               ip = td_var(to, o->off1);
-               }
+               if (o->off1)
+                       ip = td_var(to, o, o->off1);
 
                b = container_of(gopt, struct gopt_bool, gopt);
                if (ip)
 
                b = container_of(gopt, struct gopt_bool, gopt);
                if (ip)
@@ -950,12 +934,8 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                        unsigned int *ip = NULL;
                        struct gopt_combo *c;
 
                        unsigned int *ip = NULL;
                        struct gopt_combo *c;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        c = container_of(gopt, struct gopt_combo, gopt);
                        if (ip)
 
                        c = container_of(gopt, struct gopt_combo, gopt);
                        if (ip)
@@ -965,12 +945,7 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                        char *text = NULL;
 
                        if (o->off1) {
                        char *text = NULL;
 
                        if (o->off1) {
-                               char **p;
-
-                               if (o->prof_opts)
-                                       p = td_var(o->prof_opts, o->off1);
-                               else
-                                       p = td_var(to, o->off1);
+                               char **p = td_var(to, o, o->off1);
 
                                text = *p;
                        }
 
                                text = *p;
                        }
@@ -986,13 +961,7 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                char *text = NULL;
 
                if (o->off1) {
                char *text = NULL;
 
                if (o->off1) {
-                       char **p;
-
-                       if (o->prof_opts)
-                               p = td_var(o->prof_opts, o->off1);
-                       else
-                               p = td_var(to, o->off1);
-
+                       char **p = td_var(to, o, o->off1);
                        text = *p;
                }
 
                        text = *p;
                }
 
@@ -1014,19 +983,10 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o,
                break;
        case FIO_OPT_RANGE: {
                struct gopt_range *r;
                break;
        case FIO_OPT_RANGE: {
                struct gopt_range *r;
-               unsigned int *ip[4];
-
-               if (o->prof_opts) {
-                       ip[0] = td_var(o->prof_opts, o->off1);
-                       ip[1] = td_var(o->prof_opts, o->off2);
-                       ip[2] = td_var(o->prof_opts, o->off3);
-                       ip[3] = td_var(o->prof_opts, o->off4);
-               } else {
-                       ip[0] = td_var(to, o->off1);
-                       ip[1] = td_var(to, o->off2);
-                       ip[2] = td_var(to, o->off3);
-                       ip[3] = td_var(to, o->off4);
-               }
+               unsigned int *ip[4] = { td_var(to, o, o->off1),
+                                       td_var(to, o, o->off2),
+                                       td_var(to, o, o->off3),
+                                       td_var(to, o, o->off4) };
 
                r = container_of(gopt, struct gopt_range, gopt);
                gopt_int_range_set_val(r, *ip);
 
                r = container_of(gopt, struct gopt_range, gopt);
                gopt_int_range_set_val(r, *ip);
@@ -1053,12 +1013,8 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
        case FIO_OPT_STR_VAL: {
                unsigned long long *ullp = NULL;
 
        case FIO_OPT_STR_VAL: {
                unsigned long long *ullp = NULL;
 
-               if (o->off1) {
-                       if (o->prof_opts)
-                               ullp = td_var(o->prof_opts, o->off1);
-                       else
-                               ullp = td_var(to, o->off1);
-               }
+               if (o->off1)
+                       ullp = td_var(to, o, o->off1);
 
                go = gopt_new_str_val(gjv, o, ullp, opt_index);
                break;
 
                go = gopt_new_str_val(gjv, o, ullp, opt_index);
                break;
@@ -1066,12 +1022,8 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
        case FIO_OPT_STR_VAL_TIME: {
                unsigned long long *ullp = NULL;
 
        case FIO_OPT_STR_VAL_TIME: {
                unsigned long long *ullp = NULL;
 
-               if (o->off1) {
-                       if (o->prof_opts)
-                               ullp = td_var(o->prof_opts, o->off1);
-                       else
-                               ullp = td_var(to, o->off1);
-               }
+               if (o->off1)
+                       ullp = td_var(to, o, o->off1);
 
                go = gopt_new_ullong(gjv, o, ullp, opt_index);
                break;
 
                go = gopt_new_ullong(gjv, o, ullp, opt_index);
                break;
@@ -1080,23 +1032,15 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
                if (o->posval[0].ival) {
                        unsigned int *ip = NULL;
 
                if (o->posval[0].ival) {
                        unsigned int *ip = NULL;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        go = gopt_new_combo_int(gjv, o, ip, opt_index);
                } else {
                        unsigned int *ip = NULL;
 
 
                        go = gopt_new_combo_int(gjv, o, ip, opt_index);
                } else {
                        unsigned int *ip = NULL;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        go = gopt_new_int(gjv, o, ip, opt_index);
                }
 
                        go = gopt_new_int(gjv, o, ip, opt_index);
                }
@@ -1105,12 +1049,8 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
        case FIO_OPT_BOOL: {
                unsigned int *ip = NULL;
 
        case FIO_OPT_BOOL: {
                unsigned int *ip = NULL;
 
-               if (o->off1) {
-                       if (o->prof_opts)
-                               ip = td_var(o->prof_opts, o->off1);
-                       else
-                               ip = td_var(to, o->off1);
-               }
+               if (o->off1)
+                       ip = td_var(to, o, o->off1);
 
                go = gopt_new_bool(gjv, o, ip, opt_index);
                break;
 
                go = gopt_new_bool(gjv, o, ip, opt_index);
                break;
@@ -1119,12 +1059,8 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
                if (o->posval[0].ival) {
                        unsigned int *ip = NULL;
 
                if (o->posval[0].ival) {
                        unsigned int *ip = NULL;
 
-                       if (o->off1) {
-                               if (o->prof_opts)
-                                       ip = td_var(o->prof_opts, o->off1);
-                               else
-                                       ip = td_var(to, o->off1);
-                       }
+                       if (o->off1)
+                               ip = td_var(to, o, o->off1);
 
                        go = gopt_new_combo_int(gjv, o, ip, opt_index);
                } else {
 
                        go = gopt_new_combo_int(gjv, o, ip, opt_index);
                } else {
@@ -1138,13 +1074,7 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
                char *text = NULL;
 
                if (o->off1) {
                char *text = NULL;
 
                if (o->off1) {
-                       char **p;
-
-                       if (o->prof_opts)
-                               p = td_var(o->prof_opts, o->off1);
-                       else
-                               p = td_var(to, o->off1);
-
+                       char **p = td_var(to, o, o->off1);
                        text = *p;
                }
 
                        text = *p;
                }
 
@@ -1160,19 +1090,10 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox,
                go = gopt_new_str_multi(gjv, o, opt_index);
                break;
        case FIO_OPT_RANGE: {
                go = gopt_new_str_multi(gjv, o, opt_index);
                break;
        case FIO_OPT_RANGE: {
-               unsigned int *ip[4];
-
-               if (o->prof_opts) {
-                       ip[0] = td_var(o->prof_opts, o->off1);
-                       ip[1] = td_var(o->prof_opts, o->off2);
-                       ip[2] = td_var(o->prof_opts, o->off3);
-                       ip[3] = td_var(o->prof_opts, o->off4);
-               } else {
-                       ip[0] = td_var(to, o->off1);
-                       ip[1] = td_var(to, o->off2);
-                       ip[2] = td_var(to, o->off3);
-                       ip[3] = td_var(to, o->off4);
-               }
+               unsigned int *ip[4] = { td_var(to, o, o->off1),
+                                       td_var(to, o, o->off2),
+                                       td_var(to, o, o->off3),
+                                       td_var(to, o, o->off4) };
 
                go = gopt_new_int_range(gjv, o, ip, opt_index);
                break;
 
                go = gopt_new_int_range(gjv, o, ip, opt_index);
                break;
@@ -1282,17 +1203,12 @@ static void gopt_handle_str_multi_changed(struct gopt_job_view *gjv,
                                          struct gopt_str_multi *m,
                                          struct fio_option *o)
 {
                                          struct gopt_str_multi *m,
                                          struct fio_option *o)
 {
+       unsigned int *ip = td_var(gjv->o, o, o->off1);
        struct value_pair *vp;
        struct value_pair *vp;
-       unsigned int *ip;
        gboolean set;
        guint val = 0;
        int i;
 
        gboolean set;
        guint val = 0;
        int i;
 
-       if (o->prof_opts)
-               ip = td_var(o->prof_opts, o->off1);
-       else
-               ip = td_var(gjv->o, o->off1);
-
        i = 0;
        vp = &o->posval[0];
        while (vp->ival) {
        i = 0;
        vp = &o->posval[0];
        while (vp->ival) {
@@ -1317,22 +1233,13 @@ static void gopt_handle_range_changed(struct gopt_job_view *gjv,
                                      struct gopt_range *r,
                                      struct fio_option *o)
 {
                                      struct gopt_range *r,
                                      struct fio_option *o)
 {
-       unsigned int *ip[4];
+       unsigned int *ip[4] = { td_var(gjv->o, o, o->off1),
+                               td_var(gjv->o, o, o->off2),
+                               td_var(gjv->o, o, o->off3),
+                               td_var(gjv->o, o, o->off4) };
        gint val;
        int i;
 
        gint val;
        int i;
 
-       if (o->prof_opts) {
-               ip[0] = td_var(o->prof_opts, o->off1);
-               ip[1] = td_var(o->prof_opts, o->off2);
-               ip[2] = td_var(o->prof_opts, o->off3);
-               ip[3] = td_var(o->prof_opts, o->off4);
-       } else {
-               ip[0] = td_var(gjv->o, o->off1);
-               ip[1] = td_var(gjv->o, o->off2);
-               ip[2] = td_var(gjv->o, o->off3);
-               ip[3] = td_var(gjv->o, o->off4);
-       }
-
        for (i = 0; i < GOPT_RANGE_SPIN; i++) {
                val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(r->spins[i]));
                *ip[i] = val;
        for (i = 0; i < GOPT_RANGE_SPIN; i++) {
                val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(r->spins[i]));
                *ip[i] = val;
@@ -1343,15 +1250,10 @@ static void gopt_handle_str_val_changed(struct gopt_job_view *gjv,
                                        struct gopt_str_val *s,
                                        struct fio_option *o)
 {
                                        struct gopt_str_val *s,
                                        struct fio_option *o)
 {
-       unsigned long long *ullp;
+       unsigned long long *ullp = td_var(gjv->o, o, o->off1);
        GtkAdjustment *adj;
        gint index;
 
        GtkAdjustment *adj;
        gint index;
 
-       if (o->prof_opts)
-               ullp = td_var(o->prof_opts, o->off1);
-       else
-               ullp = td_var(gjv->o, o->off1);
-
        if (!ullp)
                return;
 
        if (!ullp)
                return;
 
@@ -1372,12 +1274,7 @@ static void gopt_handle_str_val_changed(struct gopt_job_view *gjv,
 static void gopt_handle_str_changed(struct gopt_job_view *gjv,
                                    struct gopt_str *s, struct fio_option *o)
 {
 static void gopt_handle_str_changed(struct gopt_job_view *gjv,
                                    struct gopt_str *s, struct fio_option *o)
 {
-       char **p;
-
-       if (o->prof_opts)
-               p = td_var(o->prof_opts, o->off1);
-       else
-               p = td_var(gjv->o, o->off1);
+       char **p = td_var(gjv->o, o, o->off1);
 
        if (*p)
                free(*p);
 
        if (*p)
                free(*p);
@@ -1388,14 +1285,9 @@ static void gopt_handle_str_changed(struct gopt_job_view *gjv,
 static void gopt_handle_bool_changed(struct gopt_job_view *gjv,
                                     struct gopt_bool *b, struct fio_option *o)
 {
 static void gopt_handle_bool_changed(struct gopt_job_view *gjv,
                                     struct gopt_bool *b, struct fio_option *o)
 {
-       unsigned int *ip;
+       unsigned int *ip = td_var(gjv->o, o, o->off1);
        gboolean set;
 
        gboolean set;
 
-       if (o->prof_opts)
-               ip = td_var(o->prof_opts, o->off1);
-       else
-               ip = td_var(gjv->o, o->off1);
-
        set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b->check));
        *ip = set;
 }
        set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b->check));
        *ip = set;
 }
@@ -1403,15 +1295,10 @@ static void gopt_handle_bool_changed(struct gopt_job_view *gjv,
 static void gopt_handle_int_changed(struct gopt_job_view *gjv,
                                    struct gopt_int *i, struct fio_option *o)
 {
 static void gopt_handle_int_changed(struct gopt_job_view *gjv,
                                    struct gopt_int *i, struct fio_option *o)
 {
+       unsigned int *ip = td_var(gjv->o, o, o->off1);
        GtkAdjustment *adj;
        GtkAdjustment *adj;
-       unsigned int *ip;
        guint val;
 
        guint val;
 
-       if (o->prof_opts)
-               ip = td_var(o->prof_opts, o->off1);
-       else
-               ip = td_var(gjv->o, o->off1);
-
        adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(i->spin));
        val = gtk_adjustment_get_value(adj);
        *ip = val;
        adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(i->spin));
        val = gtk_adjustment_get_value(adj);
        *ip = val;
@@ -1421,12 +1308,7 @@ static void gopt_handle_combo_str_changed(struct gopt_job_view *gjv,
                                          struct gopt_combo *c,
                                          struct fio_option *o)
 {
                                          struct gopt_combo *c,
                                          struct fio_option *o)
 {
-       char **p;
-
-       if (o->prof_opts)
-               p = td_var(o->prof_opts, o->off1);
-       else
-               p = td_var(gjv->o, o->off1);
+       char **p = td_var(gjv->o, o, o->off1);
 
        if (*p)
                free(*p);
 
        if (*p)
                free(*p);
@@ -1438,14 +1320,9 @@ static void gopt_handle_combo_int_changed(struct gopt_job_view *gjv,
                                          struct gopt_combo *c,
                                          struct fio_option *o)
 {
                                          struct gopt_combo *c,
                                          struct fio_option *o)
 {
-       unsigned int *ip;
+       unsigned int *ip = td_var(gjv->o, o, o->off1);
        gint index;
 
        gint index;
 
-       if (o->prof_opts)
-               ip = td_var(o->prof_opts, o->off1);
-       else
-               ip = td_var(gjv->o, o->off1);
-
        index = gtk_combo_box_get_active(GTK_COMBO_BOX(c->combo));
        *ip = o->posval[index].oval;
 }
        index = gtk_combo_box_get_active(GTK_COMBO_BOX(c->combo));
        *ip = o->posval[index].oval;
 }
index 5ee70befced30f6729f6684b725d5493c9ca22ae..9f6bc8d5ece36ba9483284307dfbbdbd9c1f859a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -3740,7 +3740,7 @@ void options_mem_dupe(void *data, struct fio_option *options)
                if (o->type != FIO_OPT_STR_STORE)
                        continue;
 
                if (o->type != FIO_OPT_STR_STORE)
                        continue;
 
-               ptr = td_var(data, o->off1);
+               ptr = td_var(data, o, o->off1);
                if (*ptr)
                        *ptr = strdup(*ptr);
        }
                if (*ptr)
                        *ptr = strdup(*ptr);
        }
diff --git a/parse.c b/parse.c
index f82bca3fdccc22af2c704eb15e9ff98e2162f537..6121dfcdd7e9efb083ada55173d8cac863549042 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -368,16 +368,13 @@ static int str_match_len(const struct value_pair *vp, const char *str)
        return max(strlen(vp->ival), opt_len(str));
 }
 
        return max(strlen(vp->ival), opt_len(str));
 }
 
-#define val_store(ptr, val, off, or, data, o)                  \
-       do {                                                    \
-               if ((o)->prof_opts)                             \
-                       ptr = td_var((o)->prof_opts, (off));    \
-               else                                            \
-                       ptr = td_var((data), (off));            \
-               if ((or))                                       \
-                       *ptr |= (val);                          \
-               else                                            \
-                       *ptr = (val);                           \
+#define val_store(ptr, val, off, or, data, o)          \
+       do {                                            \
+               ptr = td_var((data), (o), (off));       \
+               if ((or))                               \
+                       *ptr |= (val);                  \
+               else                                    \
+                       *ptr = (val);                   \
        } while (0)
 
 static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        } while (0)
 
 static int __handle_option(struct fio_option *o, const char *ptr, void *data,
@@ -526,17 +523,11 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        */
                        if (o->off2) {
                                ul2 = 0;
                        */
                        if (o->off2) {
                                ul2 = 0;
-                               if (o->prof_opts)
-                                       ilp = td_var(o->prof_opts, o->off2);
-                               else
-                                       ilp = td_var(data, o->off2);
+                               ilp = td_var(data, o, o->off2);
                                *ilp = ul2;
                        }
 
                                *ilp = ul2;
                        }
 
-                       if (o->prof_opts)
-                               flp = td_var(o->prof_opts, o->off1);
-                       else
-                               flp = td_var(data, o->off1);
+                       flp = td_var(data, o, o->off1);
                        for(i = 0; i < o->maxlen; i++)
                                flp[i].u.f = 0.0;
                }
                        for(i = 0; i < o->maxlen; i++)
                                flp[i].u.f = 0.0;
                }
@@ -560,10 +551,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        return 1;
                }
 
                        return 1;
                }
 
-               if (o->prof_opts)
-                       flp = td_var(o->prof_opts, o->off1);
-               else
-                       flp = td_var(data, o->off1);
+               flp = td_var(data, o, o->off1);
                flp[curr].u.f = uf;
 
                dprint(FD_PARSE, "  out=%f\n", uf);
                flp[curr].u.f = uf;
 
                dprint(FD_PARSE, "  out=%f\n", uf);
@@ -581,10 +569,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                len++;
 
                        if (o->off2) {
                                len++;
 
                        if (o->off2) {
-                               if (o->prof_opts)
-                                       ilp = td_var(o->prof_opts, o->off2);
-                               else
-                                       ilp = td_var(data, o->off2);
+                               ilp = td_var(data, o, o->off2);
                                if (len > *ilp)
                                        *ilp = len;
                        }
                                if (len > *ilp)
                                        *ilp = len;
                        }
@@ -596,11 +581,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                fio_opt_str_fn *fn = o->cb;
 
                if (o->off1) {
                fio_opt_str_fn *fn = o->cb;
 
                if (o->off1) {
-                       if (o->prof_opts)
-                               cp = td_var(o->prof_opts, o->off1);
-                       else
-                               cp = td_var(data, o->off1);
-
+                       cp = td_var(data, o, o->off1);
                        *cp = strdup(ptr);
                }
 
                        *cp = strdup(ptr);
                }
 
@@ -1201,10 +1182,7 @@ void options_free(struct fio_option *options, void *data)
                if (o->type != FIO_OPT_STR_STORE || !o->off1)
                        continue;
 
                if (o->type != FIO_OPT_STR_STORE || !o->off1)
                        continue;
 
-               if (o->prof_opts)
-                       ptr = td_var(o->prof_opts, o->off1);
-               else
-                       ptr = td_var(data, o->off1);
+               ptr = td_var(data, o, o->off1);
                if (*ptr) {
                        free(*ptr);
                        *ptr = NULL;
                if (*ptr) {
                        free(*ptr);
                        *ptr = NULL;
diff --git a/parse.h b/parse.h
index 66b1850ae9e753243e6289156c299bee79c447dc..8eefff90c1e88d9b77cd2dba73e41e8e3e88b047 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -100,7 +100,17 @@ typedef int (fio_opt_str_val_fn)(void *, long long *);
 typedef int (fio_opt_int_fn)(void *, int *);
 typedef int (fio_opt_str_set_fn)(void *);
 
 typedef int (fio_opt_int_fn)(void *, int *);
 typedef int (fio_opt_str_set_fn)(void *);
 
-#define td_var(start, offset)  ((void *) start + (offset))
+#define __td_var(start, offset)        ((void *) start + (offset))
+
+struct thread_options;
+static inline void *td_var(struct thread_options *to, struct fio_option *o,
+                          unsigned int offset)
+{
+       if (o->prof_opts)
+               return __td_var(o->prof_opts, offset);
+
+       return __td_var(to, offset);
+}
 
 static inline int parse_is_percent(unsigned long long val)
 {
 
 static inline int parse_is_percent(unsigned long long val)
 {