Clean up const usage to avoid excessive casting 68/1668/3
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Mon, 30 Sep 2013 21:16:20 +0000 (23:16 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Thu, 31 Oct 2013 20:42:34 +0000 (20:42 +0000)
Don't use const on pointers that hold heap allocated data, because that
means functions that free them must cast away the const.

Do use const on pointer parameters or fields that needn't be modified.

Remove pointer casts that are no longer needed after fixing the constness.

Change-Id: I5d206f5019982fd1950bc6d6d07b6062dc24e886
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1668
Tested-by: jenkins
Reviewed-by: Mathias K├╝ster <kesmtp@freenet.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
24 files changed:
src/helper/command.c
src/helper/command.h
src/helper/fileio.c
src/jtag/aice/aice_transport.c
src/jtag/core.c
src/jtag/drivers/ulink.c
src/jtag/hla/hla_tcl.c
src/jtag/jtag.h
src/jtag/tcl.c
src/rtos/ChibiOS.c
src/rtos/embKernel.c
src/rtos/linux.c
src/server/gdb_server.c
src/server/server.c
src/server/server.h
src/server/tcl_server.c
src/server/telnet_server.c
src/target/mips32_dmaacc.c
src/target/mips32_dmaacc.h
src/target/mips32_pracc.c
src/target/mips32_pracc.h
src/target/mips_m4k.c
src/target/target.c
src/target/target.h

index a179578c23790ca3a96f469132c51bacd01be8f0..b374187d061f544be7a80d93e4db1ddb434fe347 100644 (file)
@@ -146,17 +146,17 @@ void script_debug(Jim_Interp *interp, const char *name,
        free(dbg);
 }
 
-static void script_command_args_free(const char **words, unsigned nwords)
+static void script_command_args_free(char **words, unsigned nwords)
 {
        for (unsigned i = 0; i < nwords; i++)
-               free((void *)words[i]);
+               free(words[i]);
        free(words);
 }
 
-static const char **script_command_args_alloc(
+static char **script_command_args_alloc(
        unsigned argc, Jim_Obj * const *argv, unsigned *nwords)
 {
-       const char **words = malloc(argc * sizeof(char *));
+       char **words = malloc(argc * sizeof(char *));
        if (NULL == words)
                return NULL;
 
@@ -198,7 +198,7 @@ static int script_command_run(Jim_Interp *interp,
        LOG_USER_N("%s", "");   /* Keep GDB connection alive*/
 
        unsigned nwords;
-       const char **words = script_command_args_alloc(argc, argv, &nwords);
+       char **words = script_command_args_alloc(argc, argv, &nwords);
        if (NULL == words)
                return JIM_ERR;
 
@@ -299,12 +299,9 @@ static void command_free(struct command *c)
                command_free(tmp);
        }
 
-       if (c->name)
-               free((void *)c->name);
-       if (c->help)
-               free((void *)c->help);
-       if (c->usage)
-               free((void *)c->usage);
+       free(c->name);
+       free(c->help);
+       free(c->usage);
        free(c);
 }
 
@@ -362,7 +359,7 @@ static int register_command_handler(struct command_context *cmd_ctx,
        struct command *c)
 {
        Jim_Interp *interp = cmd_ctx->interp;
-       const char *ocd_name = alloc_printf("ocd_%s", c->name);
+       char *ocd_name = alloc_printf("ocd_%s", c->name);
        if (NULL == ocd_name)
                return JIM_ERR;
 
@@ -370,19 +367,19 @@ static int register_command_handler(struct command_context *cmd_ctx,
 
        Jim_CmdProc func = c->handler ? &script_command : &command_unknown;
        int retval = Jim_CreateCommand(interp, ocd_name, func, c, NULL);
-       free((void *)ocd_name);
+       free(ocd_name);
        if (JIM_OK != retval)
                return retval;
 
        /* we now need to add an overrideable proc */
-       const char *override_name = alloc_printf(
+       char *override_name = alloc_printf(
                        "proc %s {args} {eval ocd_bouncer %s $args}",
                        c->name, c->name);
        if (NULL == override_name)
                return JIM_ERR;
 
        retval = Jim_Eval_Named(interp, override_name, 0, 0);
-       free((void *)override_name);
+       free(override_name);
 
        return retval;
 }
@@ -1103,7 +1100,7 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent,
        if (help_text) {
                bool replaced = false;
                if (nc->help) {
-                       free((void *)nc->help);
+                       free(nc->help);
                        replaced = true;
                }
                nc->help = strdup(help_text);
@@ -1115,7 +1112,7 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent,
        if (usage) {
                bool replaced = false;
                if (nc->usage) {
-                       free((void *)nc->usage);
+                       free(nc->usage);
                        replaced = true;
                }
                nc->usage = strdup(usage);
index e969ad96401aa7d2e3a7be33eec701d54392058e..0f0edbb578c2089252437687c81af9622f71e70c 100644 (file)
@@ -162,9 +162,9 @@ struct command_invocation {
 typedef __COMMAND_HANDLER((*command_handler_t));
 
 struct command {
-       const char *name;
-       const char *help;
-       const char *usage;
+       char *name;
+       char *help;
+       char *usage;
        struct command *parent;
        struct command *children;
        command_handler_t handler;
index 04cfaf5914d15ab8ce264aa95d702f1a8f119a0f..c6f45e6ba78bb23d8dec0bcdb00abe2b5ee4ed15 100644 (file)
@@ -33,7 +33,7 @@
 #include "fileio.h"
 
 struct fileio_internal {
-       const char *url;
+       char *url;
        ssize_t size;
        enum fileio_type type;
        enum fileio_access access;
@@ -141,7 +141,7 @@ int fileio_close(struct fileio *fileio_p)
 
        retval = fileio_close_local(fileio);
 
-       free((void *)fileio->url);
+       free(fileio->url);
        fileio->url = NULL;
 
        free(fileio);
index 0c208bfa25ec86111bea10a26f9a2bf9350011d9..f3012bb22335941f9c1011c974b208a67ba9b79f 100644 (file)
@@ -109,7 +109,7 @@ static int jim_aice_newtap_cmd(Jim_GetOptInfo *goi)
                e = Jim_GetOpt_Nvp(goi, opts, &n);
                if (e != JIM_OK) {
                        Jim_GetOpt_NvpUnknown(goi, opts, 0);
-                       free((void *)pTap->dotted_name);
+                       free(cp);
                        free(pTap);
                        return e;
                }
@@ -118,7 +118,7 @@ static int jim_aice_newtap_cmd(Jim_GetOptInfo *goi)
                        case NTAP_OPT_EXPECTED_ID:
                                e = jim_newtap_expected_id(n, goi, pTap);
                                if (JIM_OK != e) {
-                                       free((void *)pTap->dotted_name);
+                                       free(cp);
                                        free(pTap);
                                        return e;
                                }
index b61280cc0ce2bb349a1d23f3bb041b4aba62516c..08217352116e3abf7c6f2ac5ce52c1412497978a 100644 (file)
@@ -1326,11 +1326,11 @@ void jtag_tap_free(struct jtag_tap *tap)
        jtag_unregister_event_callback(&jtag_reset_callback, tap);
 
        /** @todo is anything missing? no memory leaks please */
-       free((void *)tap->expected);
-       free((void *)tap->expected_ids);
-       free((void *)tap->chip);
-       free((void *)tap->tapname);
-       free((void *)tap->dotted_name);
+       free(tap->expected);
+       free(tap->expected_ids);
+       free(tap->chip);
+       free(tap->tapname);
+       free(tap->dotted_name);
        free(tap);
 }
 
index 9a7d8c8e9b8d117b9bc70ceed3c05956d23ea7cc..d93150d641e1d24fef071d77f2eaa1c933de0aef 100644 (file)
@@ -169,9 +169,9 @@ int ulink_usb_close(struct ulink **device);
 
 /* ULINK MCU (Cypress EZ-USB) specific functions */
 int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit);
-int ulink_load_firmware_and_renumerate(struct ulink **device, char *filename,
+int ulink_load_firmware_and_renumerate(struct ulink **device, const char *filename,
                uint32_t delay);
-int ulink_load_firmware(struct ulink *device, char *filename);
+int ulink_load_firmware(struct ulink *device, const char *filename);
 int ulink_write_firmware_section(struct ulink *device,
                struct image *firmware_image, int section_index);
 
@@ -362,7 +362,7 @@ int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit)
  * @return on failure: ERROR_FAIL
  */
 int ulink_load_firmware_and_renumerate(struct ulink **device,
-       char *filename, uint32_t delay)
+       const char *filename, uint32_t delay)
 {
        int ret;
 
@@ -397,7 +397,7 @@ int ulink_load_firmware_and_renumerate(struct ulink **device,
  * @return on success: ERROR_OK
  * @return on failure: ERROR_FAIL
  */
-int ulink_load_firmware(struct ulink *device, char *filename)
+int ulink_load_firmware(struct ulink *device, const char *filename)
 {
        struct image ulink_firmware_image;
        int ret, i;
@@ -2284,7 +2284,7 @@ COMMAND_HANDLER(ulink_download_firmware_handler)
        LOG_INFO("Downloading ULINK firmware image %s", CMD_ARGV[0]);
 
        /* Download firmware image in CMD_ARGV[0] */
-       ret = ulink_load_firmware_and_renumerate(&ulink_handle, (char *)CMD_ARGV[0],
+       ret = ulink_load_firmware_and_renumerate(&ulink_handle, CMD_ARGV[0],
                        ULINK_RENUMERATION_DELAY);
 
        return ret;
index 7bfa6a6d0c4b9222b5c297e2e6da886b396768c8..88cfc590f58c46852d6654b53b9e26b73b293c6f 100644 (file)
@@ -107,7 +107,7 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
                e = Jim_GetOpt_Nvp(goi, opts, &n);
                if (e != JIM_OK) {
                        Jim_GetOpt_NvpUnknown(goi, opts, 0);
-                       free((void *)pTap->dotted_name);
+                       free(cp);
                        free(pTap);
                        return e;
                }
@@ -116,7 +116,7 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
                case NTAP_OPT_EXPECTED_ID:
                        e = jim_newtap_expected_id(n, goi, pTap);
                        if (JIM_OK != e) {
-                               free((void *)pTap->dotted_name);
+                               free(cp);
                                free(pTap);
                                return e;
                        }
index 062563d349b5f26756959b4d28483ead996cbb6d..0fe3a4a509f89cc468ddcc43ae2e3879da09f6d3 100644 (file)
@@ -121,9 +121,9 @@ struct scan_field {
 };
 
 struct jtag_tap {
-       const char *chip;
-       const char *tapname;
-       const char *dotted_name;
+       char *chip;
+       char *tapname;
+       char *dotted_name;
        int abs_chain_position;
        /** Is this TAP disabled after JTAG reset? */
        bool disabled_after_reset;
index b95bf75665c26f538e91ef424b3289c2ca7fdaac..3f63ffc15ff8ece7f50b7f8f3b8e2ce66add9ca1 100644 (file)
@@ -563,7 +563,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
                e = Jim_GetOpt_Nvp(goi, opts, &n);
                if (e != JIM_OK) {
                        Jim_GetOpt_NvpUnknown(goi, opts, 0);
-                       free((void *)pTap->dotted_name);
+                       free(cp);
                        free(pTap);
                        return e;
                }
@@ -578,7 +578,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
                    case NTAP_OPT_EXPECTED_ID:
                            e = jim_newtap_expected_id(n, goi, pTap);
                            if (JIM_OK != e) {
-                                   free((void *)pTap->dotted_name);
+                                   free(cp);
                                    free(pTap);
                                    return e;
                            }
@@ -588,7 +588,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
                    case NTAP_OPT_IRCAPTURE:
                            e = jim_newtap_ir_param(n, goi, pTap);
                            if (JIM_OK != e) {
-                                   free((void *)pTap->dotted_name);
+                                   free(cp);
                                    free(pTap);
                                    return e;
                            }
@@ -1133,14 +1133,14 @@ COMMAND_HANDLER(handle_irscan_command)
                }
                int field_size = tap->ir_length;
                fields[i].num_bits = field_size;
-               fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8));
+               uint8_t *v = malloc(DIV_ROUND_UP(field_size, 8));
 
                uint64_t value;
                retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
                if (ERROR_OK != retval)
                        goto error_return;
-               void *v = (void *)fields[i].out_value;
                buf_set_u64(v, 0, field_size, value);
+               fields[i].out_value = v;
                fields[i].in_value = NULL;
        }
 
index 47e7fc5ddbb531a56faedac20b09bcb0c87e038f..2148e91d5277002910a326f9b3089c6d6d573e86 100644 (file)
@@ -552,6 +552,6 @@ static int ChibiOS_create(struct target *target)
                return -1;
        }
 
-       target->rtos->rtos_specific_params = (void *) &ChibiOS_params_list[i];
+       target->rtos->rtos_specific_params = &ChibiOS_params_list[i];
        return 0;
 }
index 9a45cf0b8613db1b80baa94454722c7725df81a8..f605deb3c5bd77386be1f39e1d48abc97bd66017 100644 (file)
@@ -131,7 +131,7 @@ static int embKernel_create(struct target *target)
                return -1;
        }
 
-       target->rtos->rtos_specific_params = (void *) &embKernel_params_list[i];
+       target->rtos->rtos_specific_params = &embKernel_params_list[i];
        return 0;
 }
 
index e692ada8274edd417b303fd41751869cd920fafd..2e97a421a93f4f3f10e11c8b4969c86a41497c38 100644 (file)
@@ -1524,7 +1524,7 @@ static int linux_os_create(struct target *target)
        os_linux->threads_needs_update = 0;
        os_linux->threadid_count = 1;
        os_linux->current_threads = NULL;
-       target->rtos->rtos_specific_params = (void *)os_linux;
+       target->rtos->rtos_specific_params = os_linux;
        ct->core_id = target->coreid;
        ct->threadid = -1;
        ct->TS = 0xdeadbeef;
index 660e05ef949c3be64c0e38955bfd49ffa921ca22..c49f87c1ca6da1309a7a63db97663676e0ef08b8 100644 (file)
@@ -104,8 +104,8 @@ static int gdb_breakpoint_override;
 static enum breakpoint_type gdb_breakpoint_override_type;
 
 static int gdb_error(struct connection *connection, int retval);
-static const char *gdb_port;
-static const char *gdb_port_next;
+static char *gdb_port;
+static char *gdb_port_next;
 
 static void gdb_log_callback(void *priv, const char *file, unsigned line,
                const char *function, const char *string);
@@ -2900,7 +2900,7 @@ static int gdb_target_add_one(struct target *target)
                portnumber = strtol(gdb_port_next, &end, 0);
                if (!*end) {
                        if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
-                               free((void *)gdb_port_next);
+                               free(gdb_port_next);
                                gdb_port_next = alloc_printf("%d", portnumber+1);
                        }
                }
@@ -2947,7 +2947,7 @@ COMMAND_HANDLER(handle_gdb_port_command)
 {
        int retval = CALL_COMMAND_HANDLER(server_pipe_command, &gdb_port);
        if (ERROR_OK == retval) {
-               free((void *)gdb_port_next);
+               free(gdb_port_next);
                gdb_port_next = strdup(gdb_port);
        }
        return retval;
index 01e844123e9ad373508d42a596bf1979b127be62..5e1ae36b1db0d84e2178b392f5b2b4d31f61309e 100644 (file)
@@ -303,14 +303,14 @@ static int remove_services(void)
                struct service *next = c->next;
 
                if (c->name)
-                       free((void *)c->name);
+                       free(c->name);
 
                if (c->type == CONNECTION_PIPE) {
                        if (c->fd != -1)
                                close(c->fd);
                }
                if (c->port)
-                       free((void *)c->port);
+                       free(c->port);
 
                if (c->priv)
                        free(c->priv);
@@ -612,7 +612,7 @@ int server_register_commands(struct command_context *cmd_ctx)
        return register_commands(cmd_ctx, NULL, server_command_handlers);
 }
 
-SERVER_PORT_COMMAND()
+COMMAND_HELPER(server_port_command, unsigned short *out)
 {
        switch (CMD_ARGC) {
                case 0:
@@ -631,7 +631,7 @@ SERVER_PORT_COMMAND()
        return ERROR_OK;
 }
 
-SERVER_PIPE_COMMAND()
+COMMAND_HELPER(server_pipe_command, char **out)
 {
        switch (CMD_ARGC) {
                case 0:
@@ -643,9 +643,8 @@ SERVER_PIPE_COMMAND()
                                LOG_WARNING("unable to change server port after init");
                                return ERROR_COMMAND_ARGUMENT_INVALID;
                        }
-                       const char *t = strdup(CMD_ARGV[0]);
-                       free((void *)*out);
-                       *out = t;
+                       free(*out);
+                       *out = strdup(CMD_ARGV[0]);
                        break;
                }
                default:
index e6a919537a570617adf9943e2c29bbac33003356..b444939729d9c7107a721879296736e222cc5411 100644 (file)
@@ -55,9 +55,9 @@ typedef int (*input_handler_t)(struct connection *connection);
 typedef int (*connection_closed_handler_t)(struct connection *connection);
 
 struct service {
-       const char *name;
+       char *name;
        enum connection_type type;
-       const char *port;
+       char *port;
        unsigned short portnumber;
        int fd;
        struct sockaddr_in sin;
@@ -101,14 +101,9 @@ void openocd_sleep_postlude(void);
  * Call server_port like a normal COMMAND_HANDLER with an extra @a out parameter
  * to receive the specified port number.
  */
-#define SERVER_PIPE_COMMAND() \
-       COMMAND_HELPER(server_pipe_command, const char **out)
-SERVER_PIPE_COMMAND();
+COMMAND_HELPER(server_pipe_command, char **out);
 
-#define SERVER_PORT_COMMAND() \
-       COMMAND_HELPER(server_port_command, unsigned short *out)
-
-SERVER_PORT_COMMAND();
+COMMAND_HELPER(server_port_command, unsigned short *out);
 
 #define ERROR_SERVER_REMOTE_CLOSED             (-400)
 #define ERROR_CONNECTION_REJECTED              (-401)
index f3a931ee53266f3e2fd84b879771dbab73594b76..91f9778636eaab4f99abedb126bac403f0e576bc 100644 (file)
@@ -34,7 +34,7 @@ struct tcl_connection {
        int tc_outerror;/* flag an output error */
 };
 
-static const char *tcl_port;
+static char *tcl_port;
 
 /* handlers */
 static int tcl_new_connection(struct connection *connection);
index f95178565935d7da9a4734982423b1725f321a3d..92d8c5ea6903486387b2a6fe34f28679ed27a1e9 100644 (file)
@@ -32,7 +32,7 @@
 #include <target/target_request.h>
 #include <helper/configuration.h>
 
-static const char *telnet_port;
+static char *telnet_port;
 
 static char *negotiate =
        "\xFF\xFB\x03"                  /* IAC WILL Suppress Go Ahead */
index eb6cd8ce112791a7d4f68dfbf020713464ec8da6..c2fea21ddf9595175cfda13cac4721bfebae967d 100644 (file)
@@ -38,11 +38,11 @@ static int mips32_dmaacc_read_mem32(struct mips_ejtag *ejtag_info,
                uint32_t addr, int count, uint32_t *buf);
 
 static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info,
-               uint32_t addr, int count, uint8_t *buf);
+               uint32_t addr, int count, const uint8_t *buf);
 static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info,
-               uint32_t addr, int count, uint16_t *buf);
+               uint32_t addr, int count, const uint16_t *buf);
 static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info,
-               uint32_t addr, int count, uint32_t *buf);
+               uint32_t addr, int count, const uint32_t *buf);
 
 /*
  * The following logic shamelessly cloned from HairyDairyMaid's wrt54g_debrick
@@ -407,21 +407,21 @@ static int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr,
        return ERROR_OK;
 }
 
-int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
 {
        switch (size) {
                case 1:
-                       return mips32_dmaacc_write_mem8(ejtag_info, addr, count, (uint8_t *)buf);
+                       return mips32_dmaacc_write_mem8(ejtag_info, addr, count, buf);
                case 2:
-                       return mips32_dmaacc_write_mem16(ejtag_info, addr, count, (uint16_t *)buf);
+                       return mips32_dmaacc_write_mem16(ejtag_info, addr, count, buf);
                case 4:
-                       return mips32_dmaacc_write_mem32(ejtag_info, addr, count, (uint32_t *)buf);
+                       return mips32_dmaacc_write_mem32(ejtag_info, addr, count, buf);
        }
 
        return ERROR_OK;
 }
 
-static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf)
+static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint32_t *buf)
 {
        int i;
        int retval;
@@ -435,7 +435,7 @@ static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t add
        return ERROR_OK;
 }
 
-static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
+static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint16_t *buf)
 {
        int i;
        int retval;
@@ -449,7 +449,7 @@ static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t add
        return ERROR_OK;
 }
 
-static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
+static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint8_t *buf)
 {
        int i;
        int retval;
index 15dd677bb3ba9757c6643f1305d4045bc6f814e6..45d5b3614d5b70baeae20ea5e5ca3110ac7c8af9 100644 (file)
@@ -38,6 +38,6 @@
 int mips32_dmaacc_read_mem(struct mips_ejtag *ejtag_info,
                uint32_t addr, int size, int count, void *buf);
 int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info,
-               uint32_t addr, int size, int count, void *buf);
+               uint32_t addr, int size, int count, const void *buf);
 
 #endif
index 6a66aa9a2270227f19527caae592979ddbcb2ca9..da9a2b718092c8a6788b00bd43f91b6f781ebd26 100644 (file)
@@ -730,16 +730,17 @@ static int mips32_pracc_clean_invalidate_cache(struct mips_ejtag *ejtag_info,
        return retval;
 }
 
-static int mips32_pracc_write_mem_generic(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+static int mips32_pracc_write_mem_generic(struct mips_ejtag *ejtag_info,
+               uint32_t addr, int size, int count, const void *buf)
 {
        struct pracc_queue_info ctx = {.max_code = 128 * 3 + 6 + 1};    /* alloc memory for the worst case */
        pracc_queue_init(&ctx);
        if (ctx.retval != ERROR_OK)
                goto exit;
 
-       uint32_t *buf32 = buf;
-       uint16_t *buf16 = buf;
-       uint8_t *buf8 = buf;
+       const uint32_t *buf32 = buf;
+       const uint16_t *buf16 = buf;
+       const uint8_t *buf8 = buf;
 
        while (count) {
                ctx.code_count = 0;
@@ -798,7 +799,7 @@ exit:
        return ctx.retval;
 }
 
-int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
 {
        int retval = mips32_pracc_write_mem_generic(ejtag_info, addr, size, count, buf);
        if (retval != ERROR_OK)
index 4b498559ac8c28b62301676a1a788021923347dd..4dc0bbe0d6c82a20feb6d9ed820862d4570c70a9 100644 (file)
@@ -67,7 +67,7 @@ int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info,
 int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info,
                uint32_t addr, int size, int count, void *buf);
 int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info,
-               uint32_t addr, int size, int count, void *buf);
+               uint32_t addr, int size, int count, const void *buf);
 int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source,
                int write_t, uint32_t addr, int count, uint32_t *buf);
 
index 23b1767c6be77a0e104a5d8b277f2ba9e28b7886..c2922ce946ea8188d52695c74f2c66ea0aa73353 100644 (file)
@@ -1048,9 +1048,9 @@ static int mips_m4k_write_memory(struct target *target, uint32_t address,
        /* if noDMA off, use DMAACC mode for memory write */
        int retval;
        if (ejtag_info->impcode & EJTAG_IMP_NODMA)
-               retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+               retval = mips32_pracc_write_mem(ejtag_info, address, size, count, buffer);
        else
-               retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+               retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, buffer);
 
        if (t != NULL)
                free(t);
index d78f3b1607e3d9a85975a34a4579bf9d95eeb07a..8ca1cf34faf33ee3b66fd5d7f6af9fe064edd940 100644 (file)
@@ -377,7 +377,7 @@ void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, u
 }
 
 /* write a uint32_t array to a buffer in target memory endianness */
-void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, uint32_t *srcbuf)
+void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
 {
        uint32_t i;
        for (i = 0; i < count; i++)
@@ -385,7 +385,7 @@ void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_
 }
 
 /* write a uint16_t array to a buffer in target memory endianness */
-void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, uint16_t *srcbuf)
+void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf)
 {
        uint32_t i;
        for (i = 0; i < count; i++)
@@ -4260,11 +4260,10 @@ no_params:
                                                                                   n->name);
                                        return JIM_ERR;
                                }
-                               if (target->variant)
-                                       free((void *)(target->variant));
                                e = Jim_GetOpt_String(goi, &cp, NULL);
                                if (e != JIM_OK)
                                        return e;
+                               free(target->variant);
                                target->variant = strdup(cp);
                        } else {
                                if (goi->argc != 0)
index 44f382a22c39341e70e2776972ddb1cc94abb0cb..124dc9b709b4af0bef06f8c82216d88f8216132b 100644 (file)
@@ -129,7 +129,7 @@ struct target {
        int target_number;                                      /* DO NOT USE!  field to be removed in 2010 */
        struct jtag_tap *tap;                           /* where on the jtag chain is this */
        int32_t coreid;                                         /* which device on the TAP? */
-       const char *variant;                            /* what variant of this chip is it? */
+       char *variant;                                          /* what variant of this chip is it? */
 
        /**
         * Indicates whether this target has been examined.
@@ -602,8 +602,8 @@ void target_buffer_set_u16(struct target *target, uint8_t *buffer, uint16_t valu
 
 void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, uint32_t count, uint32_t *dstbuf);
 void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, uint32_t count, uint16_t *dstbuf);
-void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, uint32_t *srcbuf);
-void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, uint16_t *srcbuf);
+void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf);
+void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf);
 
 int target_read_u32(struct target *target, uint32_t address, uint32_t *value);
 int target_read_u16(struct target *target, uint32_t address, uint16_t *value);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)