Don't cast return value of [cm]alloc

Change-Id: I0028a5b6757b1ba00031893d9a2a1725f915a0d5
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2069
Tested-by: jenkins
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Andreas Fritiofson
2014-03-28 20:00:21 +01:00
committed by Paul Fertser
parent 1171f07836
commit e6907e6d7e
14 changed files with 76 additions and 76 deletions

View File

@@ -347,17 +347,17 @@ static int ChibiOS_update_threads(struct rtos *rtos)
const char tmp_thread_name[] = "Current Execution";
const char tmp_thread_extra_info[] = "No RTOS thread";
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail));
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = (char *) malloc(
rtos->thread_details->extra_info_str = malloc(
sizeof(tmp_thread_extra_info));
strcpy(rtos->thread_details->extra_info_str, tmp_thread_extra_info);
rtos->thread_details->thread_name_str = (char *) malloc(
rtos->thread_details->thread_name_str = malloc(
sizeof(tmp_thread_name));
strcpy(rtos->thread_details->thread_name_str, tmp_thread_name);
@@ -367,7 +367,7 @@ static int ChibiOS_update_threads(struct rtos *rtos)
}
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * tasks_found);
if (!rtos->thread_details) {
LOG_ERROR("Could not allocate space for thread details");
@@ -416,7 +416,7 @@ static int ChibiOS_update_threads(struct rtos *rtos)
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
curr_thrd_details->thread_name_str = (char *)malloc(
curr_thrd_details->thread_name_str = malloc(
strlen(tmp_str) + 1);
strcpy(curr_thrd_details->thread_name_str, tmp_str);
@@ -437,7 +437,7 @@ static int ChibiOS_update_threads(struct rtos *rtos)
else
state_desc = "Unknown state";
curr_thrd_details->extra_info_str = (char *)malloc(strlen(
curr_thrd_details->extra_info_str = malloc(strlen(
state_desc)+1);
strcpy(curr_thrd_details->extra_info_str, state_desc);
@@ -498,7 +498,7 @@ static int ChibiOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, cha
static int ChibiOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
*symbol_list = malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(ChibiOS_symbol_list));
for (i = 0; i < ARRAY_SIZE(ChibiOS_symbol_list); i++)

View File

@@ -192,7 +192,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos)
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
if (!rtos->thread_details) {
LOG_ERROR("Error allocating memory for %d threads", thread_list_size);
@@ -202,7 +202,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos)
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
rtos->thread_details->thread_name_str = malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 1) {
@@ -211,7 +211,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos)
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
if (!rtos->thread_details) {
LOG_ERROR("Error allocating memory for %d threads", thread_list_size);
@@ -234,7 +234,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos)
}
symbol_address_t *list_of_lists =
(symbol_address_t *)malloc(sizeof(symbol_address_t) *
malloc(sizeof(symbol_address_t) *
(max_used_priority+1 + 5));
if (!list_of_lists) {
LOG_ERROR("Error allocating memory for %" PRId64 " priorities", max_used_priority);
@@ -320,14 +320,14 @@ static int FreeRTOS_update_threads(struct rtos *rtos)
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
rtos->thread_details[tasks_found].display_str = NULL;
rtos->thread_details[tasks_found].exists = true;
if (rtos->thread_details[tasks_found].threadid == rtos->current_thread) {
char running_str[] = "Running";
rtos->thread_details[tasks_found].extra_info_str = (char *) malloc(
rtos->thread_details[tasks_found].extra_info_str = malloc(
sizeof(running_str));
strcpy(rtos->thread_details[tasks_found].extra_info_str,
running_str);
@@ -390,7 +390,7 @@ static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, ch
static int FreeRTOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
*symbol_list = malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(FreeRTOS_symbol_list));
for (i = 0; i < ARRAY_SIZE(FreeRTOS_symbol_list); i++)
@@ -439,7 +439,7 @@ static int FreeRTOS_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
*info = (char *)malloc(strlen(tmp_str)+1);
*info = malloc(strlen(tmp_str)+1);
strcpy(*info, tmp_str);
return 0;
}

View File

@@ -175,13 +175,13 @@ static int ThreadX_update_threads(struct rtos *rtos)
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
rtos->thread_details->thread_name_str = malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 0) {
@@ -190,7 +190,7 @@ static int ThreadX_update_threads(struct rtos *rtos)
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
}
@@ -243,7 +243,7 @@ static int ThreadX_update_threads(struct rtos *rtos)
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
/* Read the thread status */
@@ -268,7 +268,7 @@ static int ThreadX_update_threads(struct rtos *rtos)
else
state_desc = "Unknown state";
rtos->thread_details[tasks_found].extra_info_str = (char *)malloc(strlen(
rtos->thread_details[tasks_found].extra_info_str = malloc(strlen(
state_desc)+1);
strcpy(rtos->thread_details[tasks_found].extra_info_str, state_desc);
@@ -331,7 +331,7 @@ static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, cha
static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
*symbol_list = malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(ThreadX_symbol_list));
for (i = 0; i < ARRAY_SIZE(ThreadX_symbol_list); i++)
@@ -412,7 +412,7 @@ static int ThreadX_get_thread_detail(struct rtos *rtos,
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
detail->thread_name_str = (char *)malloc(strlen(tmp_str)+1);
detail->thread_name_str = malloc(strlen(tmp_str)+1);
/* Read the thread status */
int64_t thread_status = 0;
@@ -437,7 +437,7 @@ static int ThreadX_get_thread_detail(struct rtos *rtos,
else
state_desc = "Unknown state";
detail->extra_info_str = (char *)malloc(strlen(state_desc)+1);
detail->extra_info_str = malloc(strlen(state_desc)+1);
detail->exists = true;

View File

@@ -170,13 +170,13 @@ static int eCos_update_threads(struct rtos *rtos)
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
rtos->thread_details->thread_name_str = malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 0) {
@@ -185,7 +185,7 @@ static int eCos_update_threads(struct rtos *rtos)
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
rtos->thread_details = malloc(
sizeof(struct thread_detail) * thread_list_size);
}
@@ -237,7 +237,7 @@ static int eCos_update_threads(struct rtos *rtos)
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
/* Read the thread status */
@@ -263,7 +263,7 @@ static int eCos_update_threads(struct rtos *rtos)
else
state_desc = "Unknown state";
rtos->thread_details[tasks_found].extra_info_str = (char *)malloc(strlen(
rtos->thread_details[tasks_found].extra_info_str = malloc(strlen(
state_desc)+1);
strcpy(rtos->thread_details[tasks_found].extra_info_str, state_desc);
@@ -359,7 +359,7 @@ static int eCos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char *
static int eCos_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
*symbol_list = malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(eCos_symbol_list));
for (i = 0; i < ARRAY_SIZE(eCos_symbol_list); i++)

View File

@@ -169,7 +169,7 @@ static int embKernel_get_tasks_details(struct rtos *rtos, int64_t iterable, cons
(uint8_t *) &priority);
if (retval != ERROR_OK)
return retval;
details->extra_info_str = (char *) malloc(EMBKERNEL_MAX_THREAD_NAME_STR_SIZE);
details->extra_info_str = malloc(EMBKERNEL_MAX_THREAD_NAME_STR_SIZE);
if (task == rtos->current_thread) {
snprintf(details->extra_info_str, EMBKERNEL_MAX_THREAD_NAME_STR_SIZE, "Pri=%u, Running",
(unsigned int) priority);
@@ -233,7 +233,7 @@ static int embKernel_update_threads(struct rtos *rtos)
}
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(sizeof(struct thread_detail) * thread_list_size);
rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
if (!rtos->thread_details) {
LOG_ERROR("Error allocating memory for %d threads", thread_list_size);
return ERROR_FAIL;
@@ -335,7 +335,7 @@ static int embKernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, c
static int embKernel_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(sizeof(symbol_table_elem_t) * ARRAY_SIZE(embKernel_symbol_list));
*symbol_list = malloc(sizeof(symbol_table_elem_t) * ARRAY_SIZE(embKernel_symbol_list));
for (i = 0; i < ARRAY_SIZE(embKernel_symbol_list); i++)
(*symbol_list)[i].symbol_name = embKernel_symbol_list[i];

View File

@@ -254,7 +254,7 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
} else {
struct threads *temp = linux_os->thread_list;
*hex_reg_list = (char *)calloc(1, 500 * sizeof(char));
*hex_reg_list = calloc(1, 500 * sizeof(char));
hex_string = *hex_reg_list;
for (i = 0; i < 16; i++)
@@ -1136,7 +1136,7 @@ int linux_gdb_thread_packet(struct target *target,
if (retval != ERROR_OK)
return ERROR_TARGET_FAILURE;
char *out_str = (char *)calloc(1, 350 * sizeof(int64_t));
char *out_str = calloc(1, 350 * sizeof(int64_t));
char *tmp_str = out_str;
tmp_str += sprintf(tmp_str, "m");
struct threads *temp = linux_os->thread_list;
@@ -1172,7 +1172,7 @@ int linux_gdb_thread_update(struct target *target,
if (found == 1) {
/*LOG_INFO("INTO GDB THREAD UPDATE FOUNDING START TASK");*/
char *out_strr = (char *)calloc(1, 350 * sizeof(int64_t));
char *out_strr = calloc(1, 350 * sizeof(int64_t));
char *tmp_strr = out_strr;
tmp_strr += sprintf(tmp_strr, "m");
/*LOG_INFO("CHAR MALLOC & M DONE");*/
@@ -1216,7 +1216,7 @@ int linux_thread_extra_info(struct target *target,
char *pid_current = "*PID: ";
char *name = "NAME: ";
int str_size = strlen(pid) + strlen(name);
char *tmp_str = (char *)calloc(1, str_size + 50);
char *tmp_str = calloc(1, str_size + 50);
char *tmp_str_ptr = tmp_str;
/* discriminate current task */
@@ -1231,7 +1231,7 @@ int linux_thread_extra_info(struct target *target,
tmp_str_ptr += sprintf(tmp_str_ptr, "%s", " | ");
sprintf(tmp_str_ptr, "%s", name);
sprintf(tmp_str_ptr, "%s", temp->name);
char *hex_str = (char *)calloc(1, strlen(tmp_str) * 2 + 1);
char *hex_str = calloc(1, strlen(tmp_str) * 2 + 1);
int pkt_len = hexify(hex_str, tmp_str, 0, strlen(tmp_str) * 2 + 1);
gdb_put_packet(connection, hex_str, pkt_len);
free(hex_str);

View File

@@ -289,7 +289,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
if (detail->extra_info_str != NULL)
str_size += strlen(detail->extra_info_str);
char *tmp_str = (char *) malloc(str_size + 7);
char *tmp_str = malloc(str_size + 7);
char *tmp_str_ptr = tmp_str;
if (detail->display_str != NULL)
@@ -309,7 +309,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
assert(strlen(tmp_str) ==
(size_t) (tmp_str_ptr - tmp_str));
char *hex_str = (char *) malloc(strlen(tmp_str) * 2 + 1);
char *hex_str = malloc(strlen(tmp_str) * 2 + 1);
int pkt_len = hexify(hex_str, tmp_str, 0, strlen(tmp_str) * 2 + 1);
gdb_put_packet(connection, hex_str, pkt_len);
@@ -334,7 +334,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
gdb_put_packet(connection, "l", 1);
} else {
/*thread id are 16 char +1 for ',' */
char *out_str = (char *) malloc(17 * target->rtos->thread_count + 1);
char *out_str = malloc(17 * target->rtos->thread_count + 1);
char *tmp_str = out_str;
for (i = 0; i < target->rtos->thread_count; i++) {
tmp_str += sprintf(tmp_str, "%c%016" PRIx64, i == 0 ? 'm' : ',',
@@ -437,7 +437,7 @@ int rtos_generic_stack_read(struct target *target,
return -5;
}
/* Read the stack */
uint8_t *stack_data = (uint8_t *) malloc(stacking->stack_registers_size);
uint8_t *stack_data = malloc(stacking->stack_registers_size);
uint32_t address = stack_ptr;
if (stacking->stack_growth_direction == 1)
@@ -456,7 +456,7 @@ int rtos_generic_stack_read(struct target *target,
#endif
for (i = 0; i < stacking->num_output_registers; i++)
list_size += stacking->register_offsets[i].width_bits/8;
*hex_reg_list = (char *)malloc(list_size*2 + 1);
*hex_reg_list = malloc(list_size*2 + 1);
tmp_str_ptr = *hex_reg_list;
new_stack_ptr = stack_ptr - stacking->stack_growth_direction *
stacking->stack_registers_size;