Remove use of forced indexing 00/244100/2
authorDewal Agarwal <d1.agarwal@samsung.com>
Tue, 15 Sep 2020 04:54:32 +0000 (10:24 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Tue, 15 Sep 2020 05:19:16 +0000 (10:49 +0530)
Change-Id: I5165e2cb41931f060fa1545e5908828e8094dcee
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
src/battery_dump/bd_history_item.c

index 8d79620..9c2b061 100644 (file)
@@ -48,7 +48,7 @@ char usage_map[32][4] = {"Bu", "Wu", "", "", "", "", "", "", "", "", "", "", "",
        "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
 GHashTable *app_map = NULL;
 static long int lst_charge = -1;
-static int front = -1, end = -1, is_full = 0;
+static int front = -1, end = -1;
 
 static int bd_dump_data_item_reset(dump_data_s* old_state)
 {
@@ -102,7 +102,6 @@ static int bd_get_index()
 
        if ((front == 0 && end == HISTORY_SIZE_MAX - 1) || (front == end + 1)) {
                _DBG("buffer is full");
-               is_full = 1;
                bd_clean_circ_buffer_front(front);
                front = (front + 1) % HISTORY_SIZE_MAX;
                /* Prepare TIME Node */
@@ -128,13 +127,12 @@ static int bd_get_index()
        return end;
 }
 
-static int bd_print_pool_entry(int fd, int idx, int pc, history_tag_s *pool_info)
+static int bd_print_pool_entry(int fd, int idx, history_tag_s *pool_info)
 {
        ENTER;
 
        BM_CHECK_INPUT_PARAM(pool_info);
        _DBG("Value from history data %d", idx);
-       _DBG("Value from history data %d", pool_info->sp_idx);
 
        GString *dump_p = g_string_sized_new(30);
        BM_CHECK_MEM_ALLOC(dump_p, {});
@@ -143,11 +141,7 @@ static int bd_print_pool_entry(int fd, int idx, int pc, history_tag_s *pool_info
        g_string_append_c(dump_p, ',');
        g_string_append(dump_p, DUMP_DATA_TAG_1);
        g_string_append_c(dump_p, ',');
-
-       if (is_full)
-               g_string_append_printf(dump_p, "%d,", pool_info->sp_idx);
-       else
-               g_string_append_printf(dump_p, "%d,", pc);
+       g_string_append_printf(dump_p, "%d,", pool_info->sp_idx);
 
        g_string_append_printf(dump_p, "%d,", pool_info->uid);
        g_string_append(dump_p, "\"");
@@ -193,7 +187,7 @@ static int bd_get_pool_entry_from_dump(int fd)
        g_string_free(dump_p, TRUE);
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
-       int pool_count = 0, index_s = front, index_e = end, i = 0;
+       int index_s = front, index_e = end, i = 0;
 
        if (index_s > index_e)
                index_e = HISTORY_SIZE_MAX + index_e;
@@ -203,22 +197,19 @@ static int bd_get_pool_entry_from_dump(int fd)
                history_tag_s *pool_info = NULL;
                if (history_data[i].event_tag != NULL && (history_data[i].event_code & ET_FLAG_START)) {
                        pool_info = history_data[i].event_tag;
-                               ret = bd_print_pool_entry(fd, i, pool_count, pool_info);
-                               pool_count++;
+                               ret = bd_print_pool_entry(fd, i, pool_info);
                                if (ret != BATTERY_MONITOR_ERROR_NONE)
                                        return BATTERY_MONITOR_ERROR_INTERNAL;
                }
                if (history_data[i].wakelock_tag != NULL) {
                        pool_info = history_data[i].wakelock_tag;
-                               ret = bd_print_pool_entry(fd, i, pool_count, pool_info);
-                               pool_count++;
+                               ret = bd_print_pool_entry(fd, i, pool_info);
                                if (ret != BATTERY_MONITOR_ERROR_NONE)
                                        return BATTERY_MONITOR_ERROR_INTERNAL;
                }
                if (history_data[i].wakereason_tag != NULL) {
                        pool_info = history_data[i].wakereason_tag;
-                               ret = bd_print_pool_entry(fd, i, pool_count, pool_info);
-                               pool_count++;
+                               ret = bd_print_pool_entry(fd, i, pool_info);
                                if (ret != BATTERY_MONITOR_ERROR_NONE)
                                        return BATTERY_MONITOR_ERROR_INTERNAL;
                }
@@ -1385,7 +1376,7 @@ static int bd_free_history_data_memory()
                        _ERR("Internal error %d while freeing at idx %d", ret , i);
        }
 
-       front = -1; end = -1; is_full = 0;
+       front = -1; end = -1;
        h_flag = true;
 
        EXIT;
@@ -1522,7 +1513,7 @@ int bd_initialize_battery_dump()
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
 
-       front = -1; end = -1; h_flag = true; is_full = 0;
+       front = -1; end = -1; h_flag = true;
        lst_charge = -1;
 #ifdef DUMP_DUMMY
        bd_dummy_test_fn();