{
ENTER;
+ if(str_data == NULL) {
+ _ERR("Invalid Stat");
+ return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
+ }
int rc = 0;
char query[BATTERY_MONITOR_SQL_LEN_MAX] = {0, };
int error_code = BATTERY_MONITOR_ERROR_NONE;
bm_gl_cpu_stat_convert_to_sql(gcpu_st, hstmt, query);
break;
default:
- break;
+ _ERR("Invalid Type");
+ return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
rc = bm_query_step(hstmt);
}
rc = bm_query_finalize(hstmt);
- BM_RETURN_VAL((rc == BATTERY_MONITOR_ERROR_NONE), {}, rc, ("finalize error"));
hstmt = NULL;
+ BM_RETURN_VAL((rc == BATTERY_MONITOR_ERROR_NONE), {}, rc, ("finalize error"));
EXIT;
return error_code;
BM_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE time_s <= %ld", table, duration);
hstmt = bm_prepare_query(bm_db_handle, query);
- if (hstmt == NULL) {
- _ERR("bm_svc_query_prepare(%s) failed(%s).\n", query, bm_db_err_msg(bm_db_handle));
- error_code = BATTERY_MONITOR_ERROR_DB_FAILED;
- goto END;
+ if (bm_db_err_code(bm_db_handle) != SQLITE_OK || hstmt == NULL) {
+ _ERR("Access failed(%s)", bm_db_err_msg(bm_db_handle));
+ return BATTERY_MONITOR_ERROR_DB_FAILED;
}
rc = bm_query_step(hstmt);
if (rc != SQLITE_DONE) {
- _ERR("The record isn't found\n");
- error_code = BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND;
- goto END;
+ _ERR("Query Failed");
+ error_code = BATTERY_MONITOR_ERROR_DB_FAILED;
}
rc = bm_query_finalize(hstmt);
if (rc != BATTERY_MONITOR_ERROR_NONE) {
_ERR("finalize error");
- error_code = rc;
- goto END;
+ error_code = BATTERY_MONITOR_ERROR_DB_FAILED;
}
hstmt = NULL;
- EXIT;
-END:
+ EXIT;
return error_code;
}
pthread_mutex_unlock(&battery_monitor_mutex);
return error_code;
}
- error_code = bm_delete_table_by_time_interval(g_hBatteryMonitorDB, BATTERY_MONITOR_GBL_NT_STAT_TABLE);
+ error_code = bm_delete_table_by_time_interval(g_hBatteryMonitorDB, BATTERY_MONITOR_GBL_CPU_STAT_TABLE);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
ret_transaction = bm_end_transaction(g_hBatteryMonitorDB, false);
- _ERR("Delete nt_stat fail, rollback delete query(%d)!!!!\n", ret_transaction);
+ _ERR("Delete gcpu_stat fail, rollback delete query(%d)!!!!\n", ret_transaction);
pthread_mutex_unlock(&battery_monitor_mutex);
return error_code;
}
pthread_mutex_unlock(&battery_monitor_mutex);
return error_code;
}
+ error_code = bm_delete_table_by_time_interval(g_hBatteryMonitorDB, BATTERY_MONITOR_GBL_NT_STAT_TABLE);
+ if (error_code != BATTERY_MONITOR_ERROR_NONE) {
+ ret_transaction = bm_end_transaction(g_hBatteryMonitorDB, false);
+ _ERR("Delete nt_stat fail, rollback delete query(%d)!!!!\n", ret_transaction);
+ pthread_mutex_unlock(&battery_monitor_mutex);
+ return error_code;
+ }
pthread_mutex_unlock(&battery_monitor_mutex);
bm_end_transaction(g_hBatteryMonitorDB, true);