From 914dde776ff22fc1c5ba3d2ed1859bb2b1e993e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 22:16:55 +0100 Subject: [PATCH] eo2: fix uninitialized vars in tests because of conditional execution of eo2_do() fct calls these vars could end up not initialized. --- src/tests/eo/composite_objects/composite_objects_comp.c | 2 +- src/tests/eo/composite_objects/composite_objects_main.c | 4 ++-- src/tests/eo/constructors/constructors_main.c | 4 +++- src/tests/eo/constructors/constructors_mixin.c | 2 +- .../eo/function_overrides/function_overrides_inherit2.c | 6 +++--- src/tests/eo/function_overrides/function_overrides_main.c | 2 +- src/tests/eo/interface/interface_main.c | 2 +- src/tests/eo/interface/interface_simple.c | 4 ++-- src/tests/eo/mixin/mixin_inherit.c | 2 +- src/tests/eo/mixin/mixin_main.c | 2 +- src/tests/eo/mixin/mixin_mixin.c | 2 +- src/tests/eo/mixin/mixin_mixin2.c | 4 ++-- src/tests/eo/mixin/mixin_mixin3.c | 4 ++-- src/tests/eo/suite/eo_test_general.c | 8 ++++---- 14 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index 9d1ec64eab..32f22da68a 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -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; diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index 9141ec5f33..b71c4cd585 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -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)); diff --git a/src/tests/eo/constructors/constructors_main.c b/src/tests/eo/constructors/constructors_main.c index 94113207b8..e40ec915a4 100644 --- a/src/tests/eo/constructors/constructors_main.c +++ b/src/tests/eo/constructors/constructors_main.c @@ -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); diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index 62ebf7bb09..69a957aee2 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -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); } diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index cf8b1cb0db..6a2369a6fc 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -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); diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 11f4c8f999..17aab2910d 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -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)); diff --git a/src/tests/eo/interface/interface_main.c b/src/tests/eo/interface/interface_main.c index b532f269e4..6fe9de131f 100644 --- a/src/tests/eo/interface/interface_main.c +++ b/src/tests/eo/interface/interface_main.c @@ -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); diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index 8a0aa1f06b..32cd9cb31b 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -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; diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c index 558c54cf04..4578b54039 100644 --- a/src/tests/eo/mixin/mixin_inherit.c +++ b/src/tests/eo/mixin/mixin_inherit.c @@ -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); diff --git a/src/tests/eo/mixin/mixin_main.c b/src/tests/eo/mixin/mixin_main.c index f6bcc15b33..a0221b3bf0 100644 --- a/src/tests/eo/mixin/mixin_main.c +++ b/src/tests/eo/mixin/mixin_main.c @@ -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... */ diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index 9b6ac802a1..0392e9099c 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -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; diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c index 80dfa8275b..621715ea86 100644 --- a/src/tests/eo/mixin/mixin_mixin2.c +++ b/src/tests/eo/mixin/mixin_mixin2.c @@ -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); } diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c index 441fd29e72..1a90847e1f 100644 --- a/src/tests/eo/mixin/mixin_mixin3.c +++ b/src/tests/eo/mixin/mixin_mixin3.c @@ -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); } diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index eb37585df9..e0a95c6cc8 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -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);