tests: Fix wrong array size for test pattern array initialization 65/299065/1
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 19 Sep 2023 05:31:42 +0000 (14:31 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 19 Sep 2023 05:55:38 +0000 (14:55 +0900)
There are arrays which used for keeping enum id of supported/not supported patterns
in INIT_PATTERN_LIST() from tests.
However, arrays were being used inappropriately.
Therefore, arrays type and initialization size are fixed.

Change-Id: I1f8d3cb9a800414177572c9182f5a29843c12788
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
tests/test-feedback.c

index 5cf7164..96e3e16 100644 (file)
@@ -123,7 +123,7 @@ bool TEST_FEEDBACK_PLAY(void)
        REPORT_AND_RETURN();
 }
 
-static void INIT_PATTERN_LIST(feedback_type_e type, feedback_pattern_e *supported, int *nsupported, feedback_pattern_e *not_supported, int *n_not_supported)
+static void INIT_PATTERN_LIST(feedback_type_e type, int *supported, int *nsupported, int *not_supported, int *n_not_supported)
 {
     int idx_supported = 0, idx_not_supported = 0;
     int i;
@@ -132,8 +132,8 @@ static void INIT_PATTERN_LIST(feedback_type_e type, feedback_pattern_e *supporte
     if (!supported || !not_supported)
         return;
 
-    memset(supported, -1, ARRAY_SIZE(test_pattern));
-    memset(not_supported, -1, ARRAY_SIZE(test_pattern));
+    memset(supported, -1, ARRAY_SIZE(test_pattern) * sizeof(int));
+    memset(not_supported, -1, ARRAY_SIZE(test_pattern) * sizeof(int));
 
     feedback_initialize();
 
@@ -150,7 +150,7 @@ static void INIT_PATTERN_LIST(feedback_type_e type, feedback_pattern_e *supporte
        if (n_not_supported) *n_not_supported = idx_not_supported;
 }
 
-static void test_play_type_p(feedback_type_e type, feedback_pattern_e *supported, int ncount)
+static void test_play_type_p(feedback_type_e type, int *supported, int ncount)
 {
        int i;
 
@@ -159,12 +159,13 @@ static void test_play_type_p(feedback_type_e type, feedback_pattern_e *supported
 
        feedback_initialize();
        for (i = 0; i < ncount; i++) {
-               RESULT(feedback_play_type(type, test_pattern[supported[i]].pattern), FEEDBACK_ERROR_NONE, test_pattern[supported[i]].name);
+               RESULT(feedback_play_type(type, test_pattern[(feedback_pattern_e)supported[i]].pattern),
+                       FEEDBACK_ERROR_NONE, test_pattern[(feedback_pattern_e)supported[i]].name);
        }
        feedback_deinitialize();
 }
 
-static void test_play_type_n(feedback_type_e type, feedback_pattern_e *notsupported, int ncount)
+static void test_play_type_n(feedback_type_e type, int *notsupported, int ncount)
 {
        int i;
 
@@ -175,7 +176,8 @@ static void test_play_type_n(feedback_type_e type, feedback_pattern_e *notsuppor
 
        feedback_initialize();
        for (i = 0; i < ncount; i++) {
-               RESULT(feedback_play_type(type, test_pattern[notsupported[i]].pattern), FEEDBACK_ERROR_NOT_SUPPORTED, test_pattern[notsupported[i]].name);
+               RESULT(feedback_play_type(type, test_pattern[(feedback_pattern_e)notsupported[i]].pattern),
+                       FEEDBACK_ERROR_NOT_SUPPORTED, test_pattern[(feedback_pattern_e)notsupported[i]].name);
        }
        feedback_deinitialize();
 }