Change the method to create dump buffers 90/225390/2
authorDewal Agarwal <d1.agarwal@samsung.com>
Wed, 19 Feb 2020 11:22:28 +0000 (16:52 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Thu, 20 Feb 2020 05:09:27 +0000 (10:39 +0530)
- Remove unnecessary assignments operation
- Add memory free before return statements

Change-Id: I3e2a4f29982d8e0295ad94791aa818f2e7e7a629
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
src/battery_dump/bd_history_item.c
src/bm_server_db.c

index c52dd14..024bf2f 100644 (file)
@@ -55,22 +55,22 @@ static int bd_print_pool_entry(int fd, int idx, history_tag_s *pool_info)
        GString *dump_p = g_string_sized_new(30);
        BM_CHECK_MEM_ALLOC(dump_p, {});
 
-       dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-       dump_p = g_string_append_c(dump_p, ',');
-       dump_p = g_string_append(dump_p, DUMP_DATA_TAG_1);
-       dump_p = g_string_append_c(dump_p, ',');
+       g_string_append(dump_p, TIZEN_DUMP_VERSION);
+       g_string_append_c(dump_p, ',');
+       g_string_append(dump_p, DUMP_DATA_TAG_1);
+       g_string_append_c(dump_p, ',');
        g_string_append_printf(dump_p, "%d,", pool_info->sp_idx);
        g_string_append_printf(dump_p, "%d,", pool_info->uid);
-       dump_p = g_string_append(dump_p, "\"");
+       g_string_append(dump_p, "\"");
 
        if (pool_info->string_info != NULL) {
                gchar *temp = g_strdup(pool_info->string_info->str);
-               dump_p = g_string_append(dump_p, temp);
+               g_string_append(dump_p, temp);
                g_free(temp);
        }
 
-       dump_p = g_string_append(dump_p, "\"");
-       dump_p = g_string_append(dump_p, "\n");
+       g_string_append(dump_p, "\"");
+       g_string_append(dump_p, "\n");
        _DBG("%s", dump_p->str);
        if (write(fd, dump_p->str, dump_p->len) < 0)
                _WARN("write error");
@@ -86,19 +86,19 @@ static int bd_get_pool_entry_from_dump(int fd)
 
        GString *dump_p = g_string_sized_new(30);
        BM_CHECK_MEM_ALLOC(dump_p, {});
-       dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-       dump_p = g_string_append(dump_p, ",0");
-       dump_p = g_string_append(dump_p, ",i");
-       dump_p = g_string_append(dump_p, ",vers");
-       dump_p = g_string_append(dump_p, ",19,150,NMF26V,NMF26V");
-       dump_p = g_string_append(dump_p, "\n");
+       g_string_append(dump_p, TIZEN_DUMP_VERSION);
+       g_string_append(dump_p, ",0");
+       g_string_append(dump_p, ",i");
+       g_string_append(dump_p, ",vers");
+       g_string_append(dump_p, ",19,150,NMF26V,NMF26V");
+       g_string_append(dump_p, "\n");
        _DBG("%s", dump_p->str);
        if (write(fd, dump_p->str, dump_p->len) < 0)
                _WARN("write error");
        g_free(dump_p->str);
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
-       int log_count = h_count;int pool_count = 0;
+       int log_count = h_count; int pool_count = 0;
        for (int i = 0; i < log_count; i++) {
                history_tag_s *pool_info = NULL;
                if (history_data[i].event_tag != NULL) {
@@ -144,10 +144,10 @@ static int bd_print_uid_entry(int idx, history_tag_s *pool_info)
        g_string_append_printf(dump_p, "%d,", pool_info->uid);
        if (pool_info->string_info != NULL) {
                gchar *temp = g_strdup(pool_info->string_info->str);
-               dump_p = g_string_append(dump_p, temp);
+               g_string_append(dump_p, temp);
                g_free(temp);
        }
-       dump_p = g_string_append(dump_p, "\n");
+       g_string_append(dump_p, "\n");
        _DBG("%s", dump_p->str);//write
        g_free(dump_p->str);
        EXIT;
@@ -161,10 +161,10 @@ static int bd_get_uid_entry_from_dump(void)
        // move there and modify
        GString *dump_p = g_string_sized_new(30);
        BM_CHECK_MEM_ALLOC(dump_p, {});
-       dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-       dump_p = g_string_append(dump_p, ",0");
-       dump_p = g_string_append(dump_p, ",i");
-       dump_p = g_string_append(dump_p, ",uid,");
+       g_string_append(dump_p, TIZEN_DUMP_VERSION);
+       g_string_append(dump_p, ",0");
+       g_string_append(dump_p, ",i");
+       g_string_append(dump_p, ",uid,");
        int ret = BATTERY_MONITOR_ERROR_NONE;
        int log_count = h_count;
        for (int i = 0; i < log_count; i++) {
@@ -294,15 +294,17 @@ static int bd_get_and_print_gbr_stat_entry_from_dump(int fd, long int duration)
        // Dump brightness Data
        bd_gl_sbr_stat_s *gbr_stat = (bd_gl_sbr_stat_s *)calloc(1, sizeof(bd_gl_sbr_stat_s));
        BM_CHECK_MEM_ALLOC(gbr_stat, {});
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gbr_stat, 3, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gbr_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gbr_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "br,");
@@ -329,15 +331,16 @@ static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int duration)
        bd_gl_ntw_stat_s *gn_stat = (bd_gl_ntw_stat_s *)calloc(1, sizeof(bd_gl_ntw_stat_s));
        BM_CHECK_MEM_ALLOC(gn_stat, {});
 
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
-
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gn_stat, 2, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gn_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gn_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "gn,");
@@ -352,7 +355,6 @@ static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int duration)
        g_string_append_printf(dump_p, "%d,", 0); //add this to struct as well
        g_string_append_printf(dump_p, "%d", 0);
        g_string_append(dump_p, "\n");
-
        _DBG("%s", dump_p->str);//write
        if (write(fd, dump_p->str, dump_p->len) < 0)
                _WARN("write error");
@@ -369,15 +371,17 @@ static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int duration)
        // Dump Wifi Stats
        bd_gl_wifi_stat_s *gwfl_stat = (bd_gl_wifi_stat_s *)calloc(1, sizeof(bd_gl_wifi_stat_s));
        BM_CHECK_MEM_ALLOC(gwfl_stat, {});
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gwfl_stat, 1, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gwfl_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gwfl_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "gwfl,");
@@ -392,7 +396,7 @@ static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int duration)
        g_free(dump_p->str);
 
        dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gwfl_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "gwfcd,");
@@ -418,15 +422,17 @@ static int bd_get_and_print_gble_stat_entry_from_dump(int fd, long int duration)
        // Dump bt Data
        bd_gl_ble_stat_s *gble_stat = (bd_gl_ble_stat_s *)calloc(1, sizeof(bd_gl_ble_stat_s));
        BM_CHECK_MEM_ALLOC(gble_stat, {});
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gble_stat, 0, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gble_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gble_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "gble,");
@@ -451,15 +457,17 @@ static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int duration)
        ENTER;
        bd_gl_sgt_stat_s *gst_stat = (bd_gl_sgt_stat_s *)calloc(1, sizeof(bd_gl_sgt_stat_s));
        BM_CHECK_MEM_ALLOC(gst_stat, {});
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gst_stat, 4, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gst_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gst_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "sgt,");
@@ -476,7 +484,7 @@ static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int duration)
        g_free(dump_p->str);
 
        dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gst_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "sst,");
@@ -499,15 +507,17 @@ static int bd_get_and_print_gwst_stat_entry_from_dump(int fd, long int duration)
        ENTER;
        bd_gl_wst_stat_s *gwst_stat = (bd_gl_wst_stat_s *)calloc(1, sizeof(bd_gl_wst_stat_s));
        BM_CHECK_MEM_ALLOC(gwst_stat, {});
-       GString *dump_p = g_string_sized_new(30);
-       BM_CHECK_MEM_ALLOC(dump_p, {});
 
        int ret = BATTERY_MONITOR_ERROR_NONE;
        ret = bm_server_battery_dump_query_from_db(gwst_stat, 5, duration);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("Unable to fetch data from DB");
+               BM_FREE(gwst_stat);
                return ret;
        }
+
+       GString *dump_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(gwst_stat); });
        g_string_append(dump_p, TIZEN_DUMP_VERSION);
        g_string_append(dump_p, ",0,l,");
        g_string_append(dump_p, "wsgt,");
@@ -542,23 +552,24 @@ static int bd_get_and_print_uid_info_entry_from_dump(int fd)
        GSList *iter = NULL; GString *dump_p = NULL;
        dump_p = g_string_sized_new(30);
        BM_CHECK_MEM_ALLOC(dump_p, {bm_set_free_gslist_appid_map(list); });
-       dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-       dump_p = g_string_append(dump_p, ",0,i,uid,1000,tizen\n");
+       g_string_append(dump_p, TIZEN_DUMP_VERSION);
+       g_string_append(dump_p, ",0,i,uid,1000,tizen\n");
        if (write(fd, dump_p->str, dump_p->len) < 0)
                _WARN("write error");
        g_free(dump_p->str);
+
        for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
                dump_p = g_string_sized_new(30);
                BM_CHECK_MEM_ALLOC(dump_p, {bm_set_free_gslist_appid_map(list); });
-               dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-               dump_p = g_string_append(dump_p, ",0");
-               dump_p = g_string_append(dump_p, ",i");
-               dump_p = g_string_append(dump_p, ",uid,");
+               g_string_append(dump_p, TIZEN_DUMP_VERSION);
+               g_string_append(dump_p, ",0");
+               g_string_append(dump_p, ",i");
+               g_string_append(dump_p, ",uid,");
                appid_map_s *amap_data = (appid_map_s *)iter->data;
                g_string_append_printf(dump_p, "%d,", (amap_data->id+10000));
                gchar *temp_str = g_strdup(amap_data->AppId);
                g_string_append(dump_p, amap_data->AppId);
-               dump_p = g_string_append(dump_p, "\n");
+               g_string_append(dump_p, "\n");
                _DBG("%s", dump_p->str);//write
                if (write(fd, dump_p->str, dump_p->len) < 0)
                        _WARN("write error");
@@ -724,11 +735,11 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                dump_p = g_string_sized_new(30);
                BM_CHECK_MEM_ALLOC(dump_p, {});
                if (chkin) {
-                       dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION);
-                       dump_p = g_string_append_c(dump_p, ',');
+                       g_string_append(dump_p, TIZEN_DUMP_VERSION);
+                       g_string_append_c(dump_p, ',');
                        _DBG("value %s", dump_p->str);
-                       dump_p = g_string_append(dump_p, DUMP_DATA_TAG);
-                       dump_p = g_string_append_c(dump_p, ',');
+                       g_string_append(dump_p, DUMP_DATA_TAG);
+                       g_string_append_c(dump_p, ',');
                        _DBG("value %s", dump_p->str);
                        if (old_state.time_s < 0) {
                                g_string_append_printf(dump_p, "%lld",
@@ -745,58 +756,58 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                }
                if (new_state.cmd_s == CM_ST) {
                        if (chkin) {
-                               dump_p = g_string_append_c(dump_p, ':');
+                               g_string_append_c(dump_p, ':');
                                _DBG("value %s", dump_p->str);
                        } else {
                                //NC
                        }
-                       dump_p = g_string_append(dump_p, "START\n");
+                       g_string_append(dump_p, "START\n");
                        _DBG("value %s", dump_p->str);
                        bd_print_history_item_reset(&old_state);
                } else if (new_state.cmd_s == CM_CRR_TIME || new_state.cmd_s == CM_RST) {
                        if (chkin) {
-                               dump_p = g_string_append_c(dump_p, ':');
+                               g_string_append_c(dump_p, ':');
                                _DBG("value %s", dump_p->str);
                        }
                        if (new_state.cmd_s == CM_RST) {
-                               dump_p = g_string_append(dump_p, "RESET:");
+                               g_string_append(dump_p, "RESET:");
                                _DBG("value %s", dump_p->str);
                                bd_print_history_item_reset(&old_state);
                        }
-                       dump_p = g_string_append(dump_p, "TIME:");
+                       g_string_append(dump_p, "TIME:");
                        _DBG("value %s", dump_p->str);
                        if (chkin) {
                                g_string_append_printf(dump_p, "%lld", new_state.time_current);
                                _DBG("value %s", dump_p->str);
-                               dump_p = g_string_append(dump_p, "\n");
+                               g_string_append(dump_p, "\n");
                                _DBG("value %s", dump_p->str);
                        } else {
                                //NC
                        }
                } else if (new_state.cmd_s == CM_SHTDN) {
                        if (chkin) {
-                               dump_p = g_string_append_c(dump_p, ':');
+                               g_string_append_c(dump_p, ':');
                                _DBG("value %s", dump_p->str);
                        } else {
                                //NC
                        }
-                       dump_p = g_string_append(dump_p, "SHUTDOWN\n");
+                       g_string_append(dump_p, "SHUTDOWN\n");
                        _DBG("value %s", dump_p->str);
                } else if (new_state.cmd_s == CM_OVRFL) {
                        if (chkin) {
-                               dump_p = g_string_append_c(dump_p, ':');
+                               g_string_append_c(dump_p, ':');
                                _DBG("value %s", dump_p->str);
                        }
-                       dump_p = g_string_append(dump_p, "*OVERFLOW*\n");
+                       g_string_append(dump_p, "*OVERFLOW*\n");
                        _DBG("value %s", dump_p->str);
                } else if (new_state.cmd_s == CM_USAGE) {
                        for (int i = 0; i < 32; i++) {
                                if (new_state.usage_type == (1 << i)) {
-                                       dump_p = g_string_append(dump_p, ",");
+                                       g_string_append(dump_p, ",");
                                        g_string_append_printf(dump_p, "%s", usage_map[i]);
-                                       dump_p = g_string_append(dump_p, "=");
+                                       g_string_append(dump_p, "=");
                                        g_string_append_printf(dump_p, "%d", new_state.usage);
-                                       dump_p = g_string_append(dump_p, "\n");
+                                       g_string_append(dump_p, "\n");
                                        _DBG("value %d", new_state.usage);
                                }
                        }
@@ -806,7 +817,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        } else {
                                if (old_state.battery_level != new_state.battery_level) {
                                        old_state.battery_level = new_state.battery_level;
-                                       dump_p = g_string_append(dump_p, ",Bl=");
+                                       g_string_append(dump_p, ",Bl=");
                                        _DBG("value %s", dump_p->str);
                                        g_string_append_printf(dump_p, "%d",
                                                        new_state.battery_level);
@@ -815,7 +826,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        }
                        if (old_state.battery_status != new_state.battery_status) {
                                old_state.battery_status = new_state.battery_status;
-                               dump_p = g_string_append(dump_p, ",Bs="); //:for NC
+                               g_string_append(dump_p, ",Bs="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_status) {
                                case BD_BSTA_UNKN:
@@ -841,7 +852,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        }
                        if (old_state.battery_health != new_state.battery_health) {
                                old_state.battery_health = new_state.battery_health;
-                               dump_p = g_string_append(dump_p, ",Bh="); //:for NC
+                               g_string_append(dump_p, ",Bh="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_health) {
                                case BD_BHLT_GOOD:
@@ -873,7 +884,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        }
                        if (old_state.battery_plugtype != new_state.battery_plugtype) {
                                old_state.battery_plugtype = new_state.battery_plugtype;
-                               dump_p = g_string_append(dump_p, ",Bp="); //:for NC
+                               g_string_append(dump_p, ",Bp="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_plugtype) {
                                case BD_BPLT_DIS:
@@ -896,21 +907,21 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        }
                        if (old_state.battery_temperature != new_state.battery_temperature) {
                                old_state.battery_temperature = new_state.battery_temperature;
-                               dump_p = g_string_append(dump_p, ",Bt="); //:for NC
+                               g_string_append(dump_p, ",Bt="); //:for NC
                                g_string_append_printf(dump_p, "%d",
                                                new_state.battery_temperature);
                                _DBG("value %s", dump_p->str);
                        }
                        if (old_state.battery_voltage != new_state.battery_voltage) {
                                old_state.battery_voltage = new_state.battery_voltage;
-                               dump_p = g_string_append(dump_p, ",Bv="); //:for NC
+                               g_string_append(dump_p, ",Bv="); //:for NC
                                _DBG("value %s", dump_p->str);
                                g_string_append_printf(dump_p, "%d", new_state.battery_voltage);
                                _DBG("value %s", dump_p->str);
                        }
                        if (old_state.battery_charge != new_state.battery_charge) {
                                old_state.battery_charge = new_state.battery_charge;
-                               dump_p = g_string_append(dump_p, ",Bcc=");
+                               g_string_append(dump_p, ",Bcc=");
                                _DBG("value %s", dump_p->str);
                                //Charge in MAh
                                g_string_append_printf(dump_p, "%d", (new_state.battery_charge/1000));
@@ -921,7 +932,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                bool wake_fl = false; int k = 0;
                                if ((change & ST1_BRIGHTNESS_MASK) != 0) {
                                        k = (new_state.state_1 & ST1_BRIGHTNESS_MASK);
-                                       dump_p = g_string_append(dump_p, ",Sb=");
+                                       g_string_append(dump_p, ",Sb=");
                                        k = k >> ST1_BRIGHTNESS_SHIFT;
                                        _DBG("Sb = %d", k);
                                        g_string_append_printf(dump_p, "%d", k);
@@ -929,7 +940,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                }
                                if ((change & ST1_PHONE_SIGNAL_STRENGTH_MASK) != 0) {
                                        k = (new_state.state_1 & ST1_PHONE_SIGNAL_STRENGTH_MASK);
-                                       dump_p = g_string_append(dump_p, ",Pss=");
+                                       g_string_append(dump_p, ",Pss=");
                                        k = k >> ST1_PHONE_SIGNAL_STRENGTH_SHIFT;
                                        _DBG("Pss = %d", k);
                                        g_string_append_printf(dump_p, "%d", k);
@@ -938,7 +949,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                int shifts = (1 << 14);
                                for (int i = 14; i < 32; i++) {
                                        if ((change & shifts) != 0) {
-                                               dump_p = g_string_append_c(dump_p, ',');
+                                               g_string_append_c(dump_p, ',');
                                                //Considering only -ve shift cases
                                                int shift = -1;
                                                if (shift < 0) {
@@ -970,7 +981,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                        shifts = (shifts << 1);
                                }
                                if (!wake_fl && new_state.wakelock_tag != NULL) {
-                                       dump_p = g_string_append(dump_p, ",w=");
+                                       g_string_append(dump_p, ",w=");
                                        if (chkin) {
                                                g_string_append_printf(dump_p, "%d",
                                                new_state.wakelock_tag->sp_idx);
@@ -984,7 +995,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                int shifts = 1;
                                for (int i = 0; i < 32; i++) {
                                        if ((change & shifts) != 0) {
-                                               dump_p = g_string_append_c(dump_p, ',');
+                                               g_string_append_c(dump_p, ',');
                                                //_DBG("value %s", dump_p->str);
                                                int shift = -1;
                                                if (shift < 0) {
@@ -1004,7 +1015,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                        }
                        if (new_state.wakereason_tag != NULL) {
                                if (chkin) {
-                                       dump_p = g_string_append(dump_p, ",wr=");
+                                       g_string_append(dump_p, ",wr=");
                                        _DBG("value %s", dump_p->str);
                                        g_string_append_printf(dump_p, "%d",
                                        new_state.wakereason_tag->sp_idx);
@@ -1014,12 +1025,12 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                //: for NC
                        }
                        if (new_state.event_code != ET_NONE) {
-                               dump_p = g_string_append_c(dump_p, ',');
+                               g_string_append_c(dump_p, ',');
                                _DBG("value %s", dump_p->str);
                                if ((new_state.event_code & ET_FLAG_START) != 0)
-                                       dump_p = g_string_append_c(dump_p, '+');
+                                       g_string_append_c(dump_p, '+');
                                else if ((new_state.event_code & ET_FLAG_FINISH) != 0)
-                                       dump_p = g_string_append_c(dump_p, '-');
+                                       g_string_append_c(dump_p, '-');
                                _DBG("value %s", dump_p->str);
                                int k = new_state.event_code & ~(ET_FLAG_START | ET_FLAG_FINISH);
                                if (k >= 0 && k < 32) {
@@ -1028,11 +1039,11 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                        _DBG("value %s", dump_p->str);
                                        g_free(temp);
                                } else {
-                                       dump_p = g_string_append(dump_p, "Ev");
+                                       g_string_append(dump_p, "Ev");
                                        g_string_append_printf(dump_p, "%d", k);
                                        _DBG("value %s", dump_p->str);
                                }
-                               dump_p = g_string_append_c(dump_p, '=');
+                               g_string_append_c(dump_p, '=');
                                _DBG("value %s", dump_p->str);
                                if (chkin) {
                                        g_string_append_printf(dump_p, "%d",
@@ -1042,7 +1053,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
                                        //: for NC
                                }
                        }
-                       dump_p = g_string_append(dump_p, "\n");
+                       g_string_append(dump_p, "\n");
                        //: step details
                        old_state.state_1 = new_state.state_1;
                        old_state.state_2 = new_state.state_2;
@@ -1060,13 +1071,13 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
        struct timeval tv;
        gettimeofday(&tv, NULL);
 
-       dump_tmp_p = g_string_append(dump_tmp_p, TIZEN_DUMP_VERSION);
-       dump_tmp_p = g_string_append_c(dump_tmp_p, ',');
-       dump_tmp_p = g_string_append(dump_tmp_p, DUMP_DATA_TAG);
-       dump_tmp_p = g_string_append_c(dump_tmp_p, ',');
+       g_string_append(dump_tmp_p, TIZEN_DUMP_VERSION);
+       g_string_append_c(dump_tmp_p, ',');
+       g_string_append(dump_tmp_p, DUMP_DATA_TAG);
+       g_string_append_c(dump_tmp_p, ',');
        g_string_append_printf(dump_tmp_p, "%lld",
                        ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000) - old_state.time_s);
-       dump_tmp_p = g_string_append(dump_tmp_p, "\n");
+       g_string_append(dump_tmp_p, "\n");
 
        if (write(fd, dump_tmp_p->str, dump_tmp_p->len) < 0)
                _WARN("write error");
index 98abad7..4c3d9ac 100644 (file)
@@ -1406,9 +1406,8 @@ CATCH:
                }
                hstmt = NULL;
        }
-       if ((*error_code != BATTERY_MONITOR_ERROR_NONE) && appid_map_list != NULL) {
+       if ((*error_code != BATTERY_MONITOR_ERROR_NONE) && appid_map_list != NULL)
                bm_set_free_gslist_appid_map(appid_map_list);
-       }
        if ((*error_code == BATTERY_MONITOR_ERROR_NONE) && appid_map_list != NULL) {
                _INFO("Returning appid map list");
                return appid_map_list;