eo2: fix uninitialized vars in tests
authorJérémy Zurcher <jeremy@asynk.ch>
Mon, 30 Dec 2013 21:16:55 +0000 (22:16 +0100)
committerTom Hacohen <tom@stosb.com>
Thu, 10 Apr 2014 03:20:20 +0000 (04:20 +0100)
because of conditional execution of eo2_do() fct calls
these vars could end up not initialized.

14 files changed:
src/tests/eo/composite_objects/composite_objects_comp.c
src/tests/eo/composite_objects/composite_objects_main.c
src/tests/eo/constructors/constructors_main.c
src/tests/eo/constructors/constructors_mixin.c
src/tests/eo/function_overrides/function_overrides_inherit2.c
src/tests/eo/function_overrides/function_overrides_main.c
src/tests/eo/interface/interface_main.c
src/tests/eo/interface/interface_simple.c
src/tests/eo/mixin/mixin_inherit.c
src/tests/eo/mixin/mixin_main.c
src/tests/eo/mixin/mixin_mixin.c
src/tests/eo/mixin/mixin_mixin2.c
src/tests/eo/mixin/mixin_mixin3.c
src/tests/eo/suite/eo_test_general.c

index 9d1ec64..32f22da 100644 (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;
index 9141ec5..b71c4cd 100644 (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));
index 9411320..e40ec91 100644 (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);
 
index 62ebf7b..69a957a 100644 (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);
 }
index cf8b1cb..6a2369a 100644 (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);
index 11f4c8f..17aab29 100644 (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));
index b532f26..6fe9de1 100644 (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);
 
index 8a0aa1f..32cd9cb 100644 (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;
index 558c54c..4578b54 100644 (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);
 
index f6bcc15..a0221b3 100644 (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... */
 
index 9b6ac80..0392e90 100644 (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;
index 80dfa82..621715e 100644 (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);
      }
index 441fd29..1a90847 100644 (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);
      }
index eb37585..e0a95c6 100644 (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);