Clean up const usage to avoid excessive casting

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>
This commit is contained in:
Andreas Fritiofson
2013-09-30 23:16:20 +02:00
committed by Spencer Oliver
parent c044c60121
commit 517ba0690d
24 changed files with 86 additions and 95 deletions

View 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;