summaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-03-19 22:06:01 +0100
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-03-21 19:13:49 +0100
commit5dcad2d34fc40659018da2cf75ceeacd3abea860 (patch)
treee3beca76ee6390f68ccb443843ea0a2e99d6dd76 /src/jtag
parent96949890ee29ab4b3ca15802302c5d93358b69e1 (diff)
downloadopenocd+libswd-5dcad2d34fc40659018da2cf75ceeacd3abea860.tar.gz
openocd+libswd-5dcad2d34fc40659018da2cf75ceeacd3abea860.tar.bz2
openocd+libswd-5dcad2d34fc40659018da2cf75ceeacd3abea860.tar.xz
openocd+libswd-5dcad2d34fc40659018da2cf75ceeacd3abea860.zip
jtag: make out_value const
Tightens up the jtag_add_xxx_scan() API Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/jtag.h4
-rw-r--r--src/jtag/tcl.c17
2 files changed, 11 insertions, 10 deletions
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index a6d16e93..cdc02ab7 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -2,7 +2,7 @@
* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
-* Copyright (C) 2007,2008 Øyvind Harboe *
+* Copyright (C) 2007-2010 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -112,7 +112,7 @@ struct scan_field {
/// The number of bits this field specifies (up to 32)
int num_bits;
/// A pointer to value to be scanned into the device
- uint8_t* out_value;
+ const uint8_t* out_value;
/// A pointer to a 32-bit memory location for data scanned out
uint8_t* in_value;
diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index 90081cdc..25516cf9 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -2,7 +2,7 @@
* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007-2010 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2009 SoftPLC Corporation *
@@ -176,9 +176,10 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
str = Jim_GetString(args[i + 1], &len);
fields[field_count].num_bits = bits;
- fields[field_count].out_value = malloc(DIV_ROUND_UP(bits, 8));
- str_to_buf(str, len, fields[field_count].out_value, bits, 0);
- fields[field_count].in_value = fields[field_count].out_value;
+ void * t = malloc(DIV_ROUND_UP(bits, 8));
+ fields[field_count].out_value = t;
+ str_to_buf(str, len, t, bits, 0);
+ fields[field_count].in_value = t;
field_count++;
}
@@ -200,7 +201,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
Jim_GetLong(interp, args[i], &bits);
str = buf_to_str(fields[field_count].in_value, bits, 16);
- free(fields[field_count].out_value);
+ free((void *)fields[field_count].out_value);
Jim_ListAppendElement(interp, list, Jim_NewStringObj(interp, str, strlen(str)));
free(str);
@@ -1511,7 +1512,7 @@ COMMAND_HANDLER(handle_irscan_command)
{
int j;
for (j = 0; j < i; j++)
- free(fields[j].out_value);
+ free((void *)fields[j].out_value);
free(fields);
command_print(CMD_CTX, "Tap: %s unknown", CMD_ARGV[i*2]);
@@ -1525,7 +1526,7 @@ COMMAND_HANDLER(handle_irscan_command)
retval = parse_u32(CMD_ARGV[i * 2 + 1], &value);
if (ERROR_OK != retval)
goto error_return;
- buf_set_u32(fields[i].out_value, 0, field_size, value);
+ buf_set_u32((void *)fields[i].out_value, 0, field_size, value);
fields[i].in_value = NULL;
}
@@ -1538,7 +1539,7 @@ error_return:
for (i = 0; i < num_fields; i++)
{
if (NULL != fields[i].out_value)
- free(fields[i].out_value);
+ free((void *)fields[i].out_value);
}
free (fields);