eo2: fix uninitialized vars in tests

because of conditional execution of eo2_do() fct calls
these vars could end up not initialized.
This commit is contained in:
Jérémy Zurcher 2013-12-30 22:16:55 +01:00 committed by Tom Hacohen
parent 63c271dc5e
commit 914dde776f
14 changed files with 25 additions and 23 deletions

View File

@ -13,7 +13,7 @@
static int
_a_get(Eo *obj, void *class_data EINA_UNUSED)
{
int a;
int a = 0;
eo2_do_super(obj, MY_CLASS, a = simple_a_get());
return a;

View File

@ -36,7 +36,7 @@ main(int argc, char *argv[])
fail_if(!eo_isa(obj, COMP_CLASS));
fail_if(!eo_isa(obj, SIMPLE_CLASS));
int a;
int a = 0;
eo2_do(obj, simple_a_set(1));
fail_if(!cb_called);
@ -44,7 +44,7 @@ main(int argc, char *argv[])
fail_if(a != 1);
/* disable the callback forwarder, and fail if it's still called. */
Eo *simple;
Eo *simple = NULL;
eo2_do(obj, simple = eo2_base_data_get("simple-obj"));
eo_ref(simple);
eo2_do(simple, eo2_event_callback_forwarder_del(EV_A_CHANGED, obj));

View File

@ -30,8 +30,10 @@ main(int argc, char *argv[])
eo2_do(obj, simple_a_set(1), simple_b_set(2));
int a, b;
int a = 0, b = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get(), mixin_add_and_print(5));
fail_if(a != 1);
fail_if(b != 2);
eo_unref(obj);

View File

@ -11,7 +11,7 @@
static void
_add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, int x)
{
int a, b;
int a = 0, b = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %d\n", __func__, a + b + x);
}

View File

@ -18,7 +18,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a)
eo2_do(obj, simple_a_print());
eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1));
Eina_Bool called;
Eina_Bool called = EINA_FALSE;
eo2_do_super(obj, MY_CLASS, called = simple_a_print());
fail_if(!called);
}
@ -26,7 +26,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a)
static Eina_Bool
_print(Eo *obj, void *class_data EINA_UNUSED)
{
Eina_Bool called;
Eina_Bool called = EINA_FALSE;
printf("Hey\n");
eo2_do_super(obj, MY_CLASS, called = inherit2_print());
fail_if(called);
@ -45,7 +45,7 @@ _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED)
static Eina_Bool
_class_print(Eo_Class *klass, void *data EINA_UNUSED)
{
Eina_Bool called;
Eina_Bool called = EINA_FALSE;
printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
eo2_do_super(klass, MY_CLASS, called = simple_class_print());
fail_if(!called);

View File

@ -17,7 +17,7 @@ main(int argc, char *argv[])
(void) argv;
eo_init();
Eina_Bool called;
Eina_Bool called = EINA_FALSE;
Eo *obj = eo2_add(INHERIT2_CLASS, NULL);
eo2_do(obj, simple_a_set(1));

View File

@ -20,7 +20,7 @@ main(int argc, char *argv[])
eo2_do(obj, simple_a_set(1), simple_b_set(2));
int a, b, sum = 0;
int a = 0, b = 0, sum = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = interface_ab_sum_get());
fail_if(sum != a + b);

View File

@ -39,7 +39,7 @@ _GET_SET_FUNC(b)
static int
_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
{
int a, b;
int a = 0, b = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
return a + b;
@ -48,7 +48,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
static int
_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED)
{
int a, b;
int a = 0, b = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
return a + b + 1;

View File

@ -12,7 +12,7 @@
static int
_a_get(Eo *obj, void *class_data EINA_UNUSED)
{
int ret;
int ret = 0;
eo2_do_super(obj, MY_CLASS, ret = simple_a_get());
printf("%s %d\n", __func__, ret);

View File

@ -22,7 +22,7 @@ main(int argc, char *argv[])
eo2_do(obj, simple_a_set(1), simple_b_set(2));
int a, b, sum = 0;
int a = 0, b = 0, sum = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = mixin_ab_sum_get());
fail_if(sum != a + b + 2); /* 2 for the two mixins... */

View File

@ -11,7 +11,7 @@
static int
_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
{
int a, b;
int a = 0, b = 0;
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
return a + b;

View File

@ -16,7 +16,7 @@ _ab_sum_get(Eo *obj, void *class_data)
{
/* This cast is a hack just for the tests... */
Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
int sum;
int sum = 0;
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get());
@ -24,7 +24,7 @@ _ab_sum_get(Eo *obj, void *class_data)
pd->count += 2;
{
int _a, _b;
int _a = 0, _b = 0;
eo2_do(obj, _a = simple_a_get(), _b = simple_b_get());
fail_if(sum != _a + _b + 1);
}

View File

@ -16,7 +16,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
{
/* This cast is just a hack for the test. */
Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data;
int sum;
int sum = 0;
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get());
@ -24,7 +24,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
pd->count += 3;
{
int _a, _b;
int _a = 0, _b = 0;
eo2_do(obj, _a = simple_a_get(), _b = simple_b_get());
fail_if(sum != _a + _b + 2);
}

View File

@ -409,7 +409,7 @@ START_TEST(eo_refs)
obj = eo2_add(SIMPLE_CLASS, NULL);
obj2 = eo2_add(SIMPLE_CLASS, obj);
Eo *wref;
Eo *wref = NULL;
eo2_do(obj2, eo2_wref_add(&wref));
fail_if(!wref);
@ -444,7 +444,7 @@ START_TEST(eo_weak_reference)
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL);
Eo *wref, *wref2, *wref3;
Eo *wref = NULL, *wref2 = NULL, *wref3 = NULL;
eo2_do(obj, eo2_wref_add(&wref));
fail_if(!wref);
@ -517,7 +517,7 @@ START_TEST(eo_generic_data)
{
eo_init();
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
void *data;
void *data = NULL;
eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL));
eo2_do(obj, data = eo2_base_data_get("test1"));
@ -615,7 +615,7 @@ START_TEST(eo_magic_checks)
fail_if(eo_class_get(obj) != SIMPLE_CLASS);
fail_if(eo_class_get(SIMPLE_CLASS) != EO2_CLASS_CLASS);
eo_class_funcs_set((Eo_Class *) buf, NULL);
eo2_do((Eo_Class *) buf, NULL);
eo2_do((Eo_Class *) buf,(void) NULL);
eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i));
eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i));
fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL);