]> git.sur5r.net Git - openocd/commitdiff
Don't cast return value of [cm]alloc
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Fri, 28 Mar 2014 19:00:21 +0000 (20:00 +0100)
committerPaul Fertser <fercerpav@gmail.com>
Sun, 30 Mar 2014 03:53:45 +0000 (03:53 +0000)
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>
14 files changed:
src/helper/replacements.c
src/jtag/drivers/versaloon/versaloon.c
src/rtos/ChibiOS.c
src/rtos/FreeRTOS.c
src/rtos/ThreadX.c
src/rtos/eCos.c
src/rtos/embKernel.c
src/rtos/linux.c
src/rtos/rtos.c
src/svf/svf.c
src/target/arm11_dbgtap.c
src/target/nds32.c
src/target/target.c
src/transport/transport.c

index b083096f8213015e61a6c001504bfff1023886a9..bb23dd92b71f9c77b9687dd4652a1f45a5b18fb8 100644 (file)
@@ -123,7 +123,7 @@ size_t strnlen(const char *s, size_t maxlen)
 char *strndup(const char *s, size_t n)
 {
        size_t len = strnlen(s, n);
-       char *new = (char *) malloc(len + 1);
+       char *new = malloc(len + 1);
 
        if (new == NULL)
                return NULL;
index 5a6c7ee38cb7764efe32b4b32a01871cfe556f73..cf14b847018531d7026230a2a9d0e23f44e37545 100644 (file)
@@ -139,7 +139,7 @@ RESULT versaloon_add_want_pos(uint16_t offset, uint16_t size, uint8_t *buff)
 {
        struct versaloon_want_pos_t *new_pos = NULL;
 
-       new_pos = (struct versaloon_want_pos_t *)malloc(sizeof(*new_pos));
+       new_pos = malloc(sizeof(*new_pos));
        if (NULL == new_pos) {
                LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
                return ERRCODE_NOT_ENOUGH_MEMORY;
index c54f43053f04fce5d4f2e083ce7d32243ed2a9f6..85da6f8114a460439c153d826ec8ad65e518ffc4 100644 (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++)
index 598e2d6627caebaf77ea5c6915abc3c7e354cf17..57307d5f24c7e53619b489d05302fd56c042f8f5 100644 (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;
 }
index add34b4f4db8b2c2da8cb3dd0032e8d74317422c..50df9ecd9290975d6a723a67af94c77d1710f7ee 100644 (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;
 
index 7310d6d64039be212284fe18f50a77488ac1a3b3..742437bb0146b8426f6e24b95e05784ae588fc48 100644 (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++)
index 76c0bd23b2857722cfd7e1464ba8acfe5d2be16b..9f5fa50f073e179529616a501f98b26ed33aaa3c 100644 (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];
index 2f5d2fb9259d43aea3f3499ecd2f1fd5c7474c66..f2a48a2559702a45efe5cc1e190447831a546f20 100644 (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);
index 1cb6958c0102dbac8ec2e0d61843f857432f8801..9ceeb2610cc482279cfafe8ee7775d73c09c7dc4 100644 (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;
index 3e7bfbf208eec69f41381badca95dbf4116b7a76..89ea80dc94dfd024c08676275ca0ba31ba48466d 100644 (file)
@@ -383,19 +383,19 @@ COMMAND_HANDLER(handle_svf_command)
        /* in case current command cannot be committed, and next command is a bit scan command */
        /* here is 32K bits for this big scan command, it should be enough */
        /* buffer will be reallocated if buffer size is not enough */
-       svf_tdi_buffer = (uint8_t *)malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
+       svf_tdi_buffer = malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
        if (NULL == svf_tdi_buffer) {
                LOG_ERROR("not enough memory");
                ret = ERROR_FAIL;
                goto free_all;
        }
-       svf_tdo_buffer = (uint8_t *)malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
+       svf_tdo_buffer = malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
        if (NULL == svf_tdo_buffer) {
                LOG_ERROR("not enough memory");
                ret = ERROR_FAIL;
                goto free_all;
        }
-       svf_mask_buffer = (uint8_t *)malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
+       svf_mask_buffer = malloc(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT);
        if (NULL == svf_mask_buffer) {
                LOG_ERROR("not enough memory");
                ret = ERROR_FAIL;
@@ -561,7 +561,7 @@ static int svf_getline(char **lineptr, size_t *n, FILE *stream)
 
        if (*lineptr == NULL) {
                *n = MIN_CHUNK;
-               *lineptr = (char *)malloc(*n);
+               *lineptr = malloc(*n);
                if (!*lineptr)
                        return -1;
        }
@@ -733,7 +733,7 @@ static int svf_adjust_array_length(uint8_t **arr, int orig_bit_len, int new_bit_
                        free(*arr);
                        *arr = NULL;
                }
-               *arr = (uint8_t *)malloc(new_byte_len);
+               *arr = malloc(new_byte_len);
                if (NULL == *arr) {
                        LOG_ERROR("not enough memory");
                        return ERROR_FAIL;
@@ -1086,7 +1086,7 @@ XXR_common:
                                        uint8_t *buffer_tmp;
 
                                        /* reallocate buffer */
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1096,7 +1096,7 @@ XXR_common:
                                        free(svf_tdi_buffer);
                                        svf_tdi_buffer = buffer_tmp;
 
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1106,7 +1106,7 @@ XXR_common:
                                        free(svf_tdo_buffer);
                                        svf_tdo_buffer = buffer_tmp;
 
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1213,7 +1213,7 @@ XXR_common:
                                        uint8_t *buffer_tmp;
 
                                        /* reallocate buffer */
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1223,7 +1223,7 @@ XXR_common:
                                        free(svf_tdi_buffer);
                                        svf_tdi_buffer = buffer_tmp;
 
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1233,7 +1233,7 @@ XXR_common:
                                        free(svf_tdo_buffer);
                                        svf_tdo_buffer = buffer_tmp;
 
-                                       buffer_tmp = (uint8_t *)malloc(svf_buffer_index + ((i + 7) >> 3));
+                                       buffer_tmp = malloc(svf_buffer_index + ((i + 7) >> 3));
                                        if (NULL == buffer_tmp) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
@@ -1456,7 +1456,7 @@ XXR_common:
                        }
                        if (num_of_argu > 2) {
                                /* STATE pathstate1 ... stable_state */
-                               path = (tap_state_t *)malloc((num_of_argu - 1) * sizeof(tap_state_t));
+                               path = malloc((num_of_argu - 1) * sizeof(tap_state_t));
                                if (NULL == path) {
                                        LOG_ERROR("not enough memory");
                                        return ERROR_FAIL;
index fd8d2540a048977adcd6ddad5213040a1ca2f56f..9271a2b96a9ba1da71d4482270fadff154b40a34 100644 (file)
@@ -591,7 +591,7 @@ int arm11_run_instr_data_to_core_noack_inner_default(struct jtag_tap *tap,
        unsigned readiesNum = count;
        unsigned bytes = sizeof(*Readies)*readiesNum;
 
-       Readies = (uint8_t *) malloc(bytes);
+       Readies = malloc(bytes);
        if (Readies == NULL) {
                LOG_ERROR("Out of memory allocating %u bytes", bytes);
                return ERROR_FAIL;
index 2295763addc9e9864ae45c5ca33a673e8e70b49a..8ab285999e2072e0f30736905b371b88abcde926 100644 (file)
@@ -2330,14 +2330,14 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
 
        switch (syscall_id) {
                case NDS32_SYSCALL_EXIT:
-                       fileio_info->identifier = (char *)malloc(5);
+                       fileio_info->identifier = malloc(5);
                        sprintf(fileio_info->identifier, "exit");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        break;
                case NDS32_SYSCALL_OPEN:
                        {
                                uint8_t filename[256];
-                               fileio_info->identifier = (char *)malloc(5);
+                               fileio_info->identifier = malloc(5);
                                sprintf(fileio_info->identifier, "open");
                                nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                                /* reserve fileio_info->param_2 for length of path */
@@ -2350,26 +2350,26 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                        }
                        break;
                case NDS32_SYSCALL_CLOSE:
-                       fileio_info->identifier = (char *)malloc(6);
+                       fileio_info->identifier = malloc(6);
                        sprintf(fileio_info->identifier, "close");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        break;
                case NDS32_SYSCALL_READ:
-                       fileio_info->identifier = (char *)malloc(5);
+                       fileio_info->identifier = malloc(5);
                        sprintf(fileio_info->identifier, "read");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        nds32_get_mapped_reg(nds32, R1, &(fileio_info->param_2));
                        nds32_get_mapped_reg(nds32, R2, &(fileio_info->param_3));
                        break;
                case NDS32_SYSCALL_WRITE:
-                       fileio_info->identifier = (char *)malloc(6);
+                       fileio_info->identifier = malloc(6);
                        sprintf(fileio_info->identifier, "write");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        nds32_get_mapped_reg(nds32, R1, &(fileio_info->param_2));
                        nds32_get_mapped_reg(nds32, R2, &(fileio_info->param_3));
                        break;
                case NDS32_SYSCALL_LSEEK:
-                       fileio_info->identifier = (char *)malloc(6);
+                       fileio_info->identifier = malloc(6);
                        sprintf(fileio_info->identifier, "lseek");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        nds32_get_mapped_reg(nds32, R1, &(fileio_info->param_2));
@@ -2378,7 +2378,7 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                case NDS32_SYSCALL_UNLINK:
                        {
                                uint8_t filename[256];
-                               fileio_info->identifier = (char *)malloc(7);
+                               fileio_info->identifier = malloc(7);
                                sprintf(fileio_info->identifier, "unlink");
                                nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                                /* reserve fileio_info->param_2 for length of path */
@@ -2391,7 +2391,7 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                case NDS32_SYSCALL_RENAME:
                        {
                                uint8_t filename[256];
-                               fileio_info->identifier = (char *)malloc(7);
+                               fileio_info->identifier = malloc(7);
                                sprintf(fileio_info->identifier, "rename");
                                nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                                /* reserve fileio_info->param_2 for length of old path */
@@ -2408,7 +2408,7 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                        }
                        break;
                case NDS32_SYSCALL_FSTAT:
-                       fileio_info->identifier = (char *)malloc(6);
+                       fileio_info->identifier = malloc(6);
                        sprintf(fileio_info->identifier, "fstat");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        nds32_get_mapped_reg(nds32, R1, &(fileio_info->param_2));
@@ -2416,7 +2416,7 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                case NDS32_SYSCALL_STAT:
                        {
                                uint8_t filename[256];
-                               fileio_info->identifier = (char *)malloc(5);
+                               fileio_info->identifier = malloc(5);
                                sprintf(fileio_info->identifier, "stat");
                                nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                                /* reserve fileio_info->param_2 for length of old path */
@@ -2428,20 +2428,20 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                        }
                        break;
                case NDS32_SYSCALL_GETTIMEOFDAY:
-                       fileio_info->identifier = (char *)malloc(13);
+                       fileio_info->identifier = malloc(13);
                        sprintf(fileio_info->identifier, "gettimeofday");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        nds32_get_mapped_reg(nds32, R1, &(fileio_info->param_2));
                        break;
                case NDS32_SYSCALL_ISATTY:
-                       fileio_info->identifier = (char *)malloc(7);
+                       fileio_info->identifier = malloc(7);
                        sprintf(fileio_info->identifier, "isatty");
                        nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                        break;
                case NDS32_SYSCALL_SYSTEM:
                        {
                                uint8_t command[256];
-                               fileio_info->identifier = (char *)malloc(7);
+                               fileio_info->identifier = malloc(7);
                                sprintf(fileio_info->identifier, "system");
                                nds32_get_mapped_reg(nds32, R0, &(fileio_info->param_1));
                                /* reserve fileio_info->param_2 for length of old path */
@@ -2452,12 +2452,12 @@ int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fil
                        }
                        break;
                case NDS32_SYSCALL_ERRNO:
-                       fileio_info->identifier = (char *)malloc(6);
+                       fileio_info->identifier = malloc(6);
                        sprintf(fileio_info->identifier, "errno");
                        nds32_set_mapped_reg(nds32, R0, nds32->virtual_hosting_errno);
                        break;
                default:
-                       fileio_info->identifier = (char *)malloc(8);
+                       fileio_info->identifier = malloc(8);
                        sprintf(fileio_info->identifier, "unknown");
                        break;
        }
index 9820155467b4176dfd0e6f5fe5d27f26adf23787..32ab1178227665124178bb360481f1972a787fce 100644 (file)
@@ -3190,7 +3190,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
                                if (diffs == 0)
                                        LOG_ERROR("checksum mismatch - attempting binary compare");
 
-                               data = (uint8_t *)malloc(buf_cnt);
+                               data = malloc(buf_cnt);
 
                                /* Can we use 32bit word accesses? */
                                int size = 1;
@@ -5102,7 +5102,7 @@ static int target_create(Jim_GetOptInfo *goi)
        target->target_number = new_target_number();
 
        /* allocate memory for each unique target type */
-       target->type = (struct target_type *)calloc(1, sizeof(struct target_type));
+       target->type = calloc(1, sizeof(struct target_type));
 
        memcpy(target->type, target_types[x], sizeof(struct target_type));
 
@@ -5488,7 +5488,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
        image_size = 0x0;
        retval = ERROR_OK;
        fastload_num = image.num_sections;
-       fastload = (struct FastLoad *)malloc(sizeof(struct FastLoad)*image.num_sections);
+       fastload = malloc(sizeof(struct FastLoad)*image.num_sections);
        if (fastload == NULL) {
                command_print(CMD_CTX, "out of memory");
                image_close(&image);
index 06f09c99882137242a4b4c7dfe171b4b7e3410e1..35194b51c142ae6daee92eb7deeac095d262d063 100644 (file)
@@ -206,7 +206,7 @@ COMMAND_HELPER(transport_list_parse, char ***vector)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        /* our return vector must be NULL terminated */
-       argv = (char **) calloc(n + 1, sizeof(char *));
+       argv = calloc(n + 1, sizeof(char *));
        if (argv == NULL)
                return ERROR_FAIL;