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

@@ -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)