#define CPU_CONTENTION_HANDLE_TIMEOUT_MSEC 500
#define SOCK_PATH "/run/.resourced.socket"
+#define CPU_BOOSTING_LEVEL_STR(level) \
+ (level == CPU_BOOSTING_LEVEL_STRONG ? "CPU_BOOSTING_LEVEL_STRONG" : \
+ level == CPU_BOOSTING_LEVEL_MEDIUM ? "CPU_BOOSTING_LEVEL_MEDIUM" : \
+ level == CPU_BOOSTING_LEVEL_WEAK ? "CPU_BOOSTING_LEVEL_WEAK" : \
+ level == CPU_BOOSTING_LEVEL_NONE ? "CPU_BOOSTING_LEVEL_NONE" : "Unknown CPU boosting level")
+
/**
* Information to restore CPU boosting level
* before dealing with CPU contention
(struct syscommon_resourced_cpu_boosting_info *)data;
uint32_t cpu_boosting_info_set_flag = 0;
- assert(cpu_boosting_info);
+ if (cpu_boosting_info == NULL) {
+ _E("Failed to free CPU boosting info structure due to null pointer");
+ return;
+ }
cpu_boosting_info_set_flag = CPU_BOOSTING_INFO_SET_REF_CNT;
set_cpu_boosting_info(cpu_boosting_info_set_flag,
struct cpu_contention_handle_data *cpu_contention_handle_data =
(struct cpu_contention_handle_data *)data;
- assert(cpu_contention_handle_data);
+ if (cpu_contention_handle_data == NULL) {
+ _E("Failed to free cpu_contention_handle_data due to null pointer");
+ return;
+ }
g_slice_free(struct cpu_contention_handle_data,
cpu_contention_handle_data);
static void find_cpu_boosting_info_in_tables(
struct syscommon_resourced_cpu_boosting_info **cpu_boosting_info, int *tid)
{
- assert(cpu_boosting_info);
+ if (cpu_boosting_info == NULL) {
+ _E("Failed to find CPU boosting info structure due to null pointer");
+ return;
+ }
for (cpu_boosting_level_e cpu_boosting_level = CPU_BOOSTING_LEVEL_STRONG;
cpu_boosting_level < CPU_BOOSTING_LEVEL_END; cpu_boosting_level++) {
{
struct cpu_contention_handle_data *cpu_contention_handle_data = NULL;
- assert(input);
+ if (input == NULL) {
+ _E("CPU boosting input argument cannot be null");
+ return;
+ }
/**
* Register information to restore cpu boosting level
g_source_unref(source);
gslist_for_each_safe(action_list, iter, next, input) {
- assert(input);
+ if (input == NULL) {
+ _W("syscommon_resourced_cpu_boosting_input cannot be null");
+ continue;
+ }
register_cpu_contention_handle_data(input, cpu_boosting_level,
*timer_id);
static int cpu_boosting_enqueue_by_conf(void *data,
struct syscommon_resourced_cpu_boosting_input **input)
{
- assert(data);
+ if (data == NULL) {
+ _E("Input argument data cannot be null");
+ return RESOURCED_ERROR_INVALID_PARAMETER;
+ }
int ret;
struct proc_status *ps = (struct proc_status *)data;
continue;
if (!is_valid_cpu_boosting_level(cpu_boosting_info->level)) {
- _E("[CPU-BOOSTING] Unknown cpu boosting level (SIGABT)");
- assert(0);
+ _W("[CPU-BOOSTING] Unknown cpu boosting level (%s)",
+ CPU_BOOSTING_LEVEL_STR(cpu_boosting_info->level));
+ continue;
}
g_hash_table_remove(g_cpu_boosting_info_table[cpu_boosting_info->level],
for (int level = CPU_BOOSTING_LEVEL_STRONG; level < CPU_BOOSTING_LEVEL_END; level++) {
g_cpu_boosting_info_table[level] = g_hash_table_new_full(
g_int_hash, g_int_equal, NULL, free_cpu_boosting_info);
- g_assert(g_cpu_boosting_info_table[level]);
+
+ if (g_cpu_boosting_info_table[level] == NULL)
+ _W("Global CPU boosting info table of level (%s) cannot be null",
+ CPU_BOOSTING_LEVEL_STR(level));
}
dest_table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
cpu_boosting_destroy_request);
- g_assert(dest_table);
+ if (dest_table == NULL) {
+ _E("A hash table for CPU boosting inheritance cannot be null");
+ return RESOURCED_ERROR_FAIL;
+ }
g_cpu_contention_handle_data_table =
g_hash_table_new_full(g_int_hash, g_int_equal, NULL,
free_cpu_contention_handle_data);
- g_assert(g_cpu_contention_handle_data_table);
+ if (g_cpu_contention_handle_data_table == NULL) {
+ _E("A hash table for CPU governor cannot be null");
+ return RESOURCED_ERROR_FAIL;
+ }
/* For the conf-based client */
register_notifier(RESOURCED_NOTIFIER_BOOSTING_RESOURCE, cpu_boosting_recv_from_conf);