gfio: apply inverse options to buffered/direct

For these, we'd ideally use radio buttons instead. But hard to
pass that info from the options structure, so lets just punt
to inverse check buttons for now.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/goptions.c b/goptions.c
index 547d9cf..4069a17 100644
--- a/goptions.c
+++ b/goptions.c
@@ -31,6 +31,7 @@
 
 struct gopt_bool {
 	struct gopt gopt;
+	unsigned int in_change;
 	GtkWidget *check;
 };
 
@@ -143,6 +144,7 @@
 	GtkWidget *label;
 
 	s = malloc(sizeof(*s));
+	memset(s, 0, sizeof(*s));
 
 	s->gopt.box = gtk_hbox_new(FALSE, 3);
 	if (!o->lname)
@@ -180,6 +182,7 @@
 	GtkWidget *label;
 
 	c = malloc(sizeof(*c));
+	memset(c, 0, sizeof(*c));
 
 	c->gopt.box = gtk_hbox_new(FALSE, 3);
 	if (!o->lname)
@@ -252,6 +255,7 @@
 	int i;
 
 	m = malloc(sizeof(*m));
+	memset(m, 0, sizeof(*m));
 	m->gopt.box = gtk_hbox_new(FALSE, 3);
 	gopt_mark_index(&m->gopt, idx);
 
@@ -292,6 +296,8 @@
 		struct gopt_int *i_inv = o->inv_opt->gui_data;
 		int cur_val;
 
+		assert(o->type == o->inv_opt->type);
+
 		/*
 		 * Don't recourse into notify changes. Is there a better
 		 * way than this? We essentially want to block the update
@@ -317,6 +323,7 @@
 	GtkWidget *label;
 
 	i = malloc(sizeof(*i));
+	memset(i, 0, sizeof(*i));
 	i->gopt.box = gtk_hbox_new(FALSE, 3);
 	if (!o->lname)
 		label = gtk_label_new(o->name);
@@ -385,6 +392,25 @@
 	gboolean set;
 
 	set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b->check));
+
+	if (o->inv_opt) {
+		struct gopt_bool *b_inv = o->inv_opt->gui_data;
+
+		assert(o->type == o->inv_opt->type);
+
+		/*
+		 * Don't recourse into notify changes. Is there a better
+		 * way than this? We essentially want to block the update
+		 * signal while we perform the below set_value().
+		 */
+		if (b_inv->in_change)
+			return;
+
+		b->in_change = 1;
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b_inv->check), !set);
+		b->in_change = 0;
+	}
+
 	gopt_set_children_visible(o, set);
 }
 
@@ -395,6 +421,7 @@
 	int defstate = 0;
 
 	b = malloc(sizeof(*b));
+	memset(b, 0, sizeof(*b));
 	b->gopt.box = gtk_hbox_new(FALSE, 3);
 	if (!o->lname)
 		label = gtk_label_new(o->name);
@@ -470,6 +497,7 @@
 	int i;
 
 	r = malloc(sizeof(*r));
+	memset(r, 0, sizeof(*r));
 	r->gopt.box = gtk_hbox_new(FALSE, 3);
 	gopt_mark_index(&r->gopt, idx);
 	if (!o->lname)
diff --git a/options.c b/options.c
index 1b0117e..88b9142 100644
--- a/options.c
+++ b/options.c
@@ -1596,6 +1596,7 @@
 		.off1	= td_var_offset(odirect),
 		.help	= "Use O_DIRECT IO (negates buffered)",
 		.def	= "0",
+		.inverse = "buffered",
 		.category = FIO_OPT_C_IO,
 		.group	= FIO_OPT_G_INVALID,
 	},
@@ -1607,6 +1608,7 @@
 		.neg	= 1,
 		.help	= "Use buffered IO (negates direct)",
 		.def	= "1",
+		.inverse = "direct",
 		.category = FIO_OPT_C_IO,
 		.group	= FIO_OPT_G_INVALID,
 	},