summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-10 04:27:15 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-11 11:53:22 -0800
commitca594adb5a71f2bf60c1380172b8e61b075d9479 (patch)
treec4702f927f5991c0075479259e0562db1c941cc4 /src
parent9741e126fd854815460296ad47d027129c7f17bf (diff)
downloadopenocd+libswd-ca594adb5a71f2bf60c1380172b8e61b075d9479.tar.gz
openocd+libswd-ca594adb5a71f2bf60c1380172b8e61b075d9479.tar.bz2
openocd+libswd-ca594adb5a71f2bf60c1380172b8e61b075d9479.tar.xz
openocd+libswd-ca594adb5a71f2bf60c1380172b8e61b075d9479.zip
add const keyword to some APIs
Add 'const' keyword to 'char *' parameters to allow command handlers to pass constant string arguments. These changes allow the 'args' command handler to be changed to 'const' in a subsequent patch.
Diffstat (limited to 'src')
-rw-r--r--src/flash/flash.c2
-rw-r--r--src/flash/flash.h2
-rw-r--r--src/flash/lpc2900.c6
-rw-r--r--src/flash/nand.c2
-rw-r--r--src/flash/nand.h2
-rw-r--r--src/pld/pld.h2
-rw-r--r--src/pld/virtex2.c2
-rw-r--r--src/pld/xilinx_bit.c2
-rw-r--r--src/pld/xilinx_bit.h2
-rw-r--r--src/target/image.c6
-rw-r--r--src/target/image.h2
-rw-r--r--src/target/register.c3
-rw-r--r--src/target/register.h3
-rw-r--r--src/target/target.c2
-rw-r--r--src/xsvf/xsvf.c4
15 files changed, 22 insertions, 20 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c
index 451abdc6..1a04e123 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -199,7 +199,7 @@ flash_bank_t *get_flash_bank_by_num(int num)
}
int flash_command_get_bank_by_num(
- struct command_context_s *cmd_ctx, char *str, flash_bank_t **bank)
+ struct command_context_s *cmd_ctx, const char *str, flash_bank_t **bank)
{
unsigned bank_num;
COMMAND_PARSE_NUMBER(uint, str, bank_num);
diff --git a/src/flash/flash.h b/src/flash/flash.h
index fd3c4c29..648bd738 100644
--- a/src/flash/flash.h
+++ b/src/flash/flash.h
@@ -326,7 +326,7 @@ flash_bank_t *get_flash_bank_by_num(int num);
* @returns ERROR_OK on success, or an error indicating the problem.
*/
int flash_command_get_bank_by_num(struct command_context_s *cmd_ctx,
- char *str, flash_bank_t **bank);
+ const char *str, flash_bank_t **bank);
/**
* Returns the flash bank like get_flash_bank_by_num(), without probing.
* @param num The flash bank number.
diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c
index f2daab4c..251f682f 100644
--- a/src/flash/lpc2900.c
+++ b/src/flash/lpc2900.c
@@ -635,7 +635,7 @@ static int lpc2900_handle_read_custom_command( struct command_context_s *cmd_ctx
/* Try and open the file */
fileio_t fileio;
- char *filename = args[1];
+ const char *filename = args[1];
int ret = fileio_open( &fileio, filename, FILEIO_WRITE, FILEIO_BINARY );
if( ret != ERROR_OK )
{
@@ -747,8 +747,8 @@ static int lpc2900_handle_write_custom_command( struct command_context_s *cmd_ct
image.base_address = 0;
image.start_address_set = 0;
- char *filename = args[1];
- char *type = (argc >= 3) ? args[2] : NULL;
+ const char *filename = args[1];
+ const char *type = (argc >= 3) ? args[2] : NULL;
retval = image_open(&image, filename, type);
if (retval != ERROR_OK)
{
diff --git a/src/flash/nand.c b/src/flash/nand.c
index ea1cb9e6..c1be276d 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -304,7 +304,7 @@ nand_device_t *get_nand_device_by_num(int num)
}
int nand_command_get_device_by_num(struct command_context_s *cmd_ctx,
- char *str, nand_device_t **device)
+ const char *str, nand_device_t **device)
{
unsigned num;
COMMAND_PARSE_NUMBER(uint, str, num);
diff --git a/src/flash/nand.h b/src/flash/nand.h
index 16558c2b..5b19d5a9 100644
--- a/src/flash/nand.h
+++ b/src/flash/nand.h
@@ -226,7 +226,7 @@ int nand_init(struct command_context_s *cmd_ctx);
/// helper for parsing a nand device command argument string
int nand_command_get_device_by_num(struct command_context_s *cmd_ctx,
- char *str, nand_device_t **device);
+ const char *str, nand_device_t **device);
#define ERROR_NAND_DEVICE_INVALID (-1100)
diff --git a/src/pld/pld.h b/src/pld/pld.h
index c6d3c924..3db4bad0 100644
--- a/src/pld/pld.h
+++ b/src/pld/pld.h
@@ -29,7 +29,7 @@ typedef struct pld_driver_s
char *name;
int (*register_commands)(struct command_context_s *cmd_ctx);
int (*pld_device_command)(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct pld_device_s *pld_device);
- int (*load)(struct pld_device_s *pld_device, char *filename);
+ int (*load)(struct pld_device_s *pld_device, const char *filename);
} pld_driver_t;
typedef struct pld_device_s
diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c
index 28cae6ca..ec0847fe 100644
--- a/src/pld/virtex2.c
+++ b/src/pld/virtex2.c
@@ -143,7 +143,7 @@ static int virtex2_read_stat(struct pld_device_s *pld_device, uint32_t *status)
return ERROR_OK;
}
-static int virtex2_load(struct pld_device_s *pld_device, char *filename)
+static int virtex2_load(struct pld_device_s *pld_device, const char *filename)
{
virtex2_pld_device_t *virtex2_info = pld_device->driver_priv;
xilinx_bit_file_t bit_file;
diff --git a/src/pld/xilinx_bit.c b/src/pld/xilinx_bit.c
index c766805f..33c3ed79 100644
--- a/src/pld/xilinx_bit.c
+++ b/src/pld/xilinx_bit.c
@@ -75,7 +75,7 @@ static int read_section(FILE *input_file, int length_size, char section,
return ERROR_OK;
}
-int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, char *filename)
+int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, const char *filename)
{
FILE *input_file;
struct stat input_stat;
diff --git a/src/pld/xilinx_bit.h b/src/pld/xilinx_bit.h
index f9b96a7b..3eb331ba 100644
--- a/src/pld/xilinx_bit.h
+++ b/src/pld/xilinx_bit.h
@@ -33,6 +33,6 @@ typedef struct xilinx_bit_file_s
uint8_t *data;
} xilinx_bit_file_t;
-int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, char *filename);
+int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, const char *filename);
#endif /* XILINX_BIT_H */
diff --git a/src/target/image.c b/src/target/image.c
index b9e641b3..cf7e11ab 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -44,7 +44,7 @@
((elf->endianness == ELFDATA2LSB)? \
le_to_h_u32((uint8_t*)&field):be_to_h_u32((uint8_t*)&field))
-static int autodetect_image_type(image_t *image, char *url)
+static int autodetect_image_type(image_t *image, const char *url)
{
int retval;
fileio_t fileio;
@@ -106,7 +106,7 @@ static int autodetect_image_type(image_t *image, char *url)
return ERROR_OK;
}
-static int identify_image_type(image_t *image, char *type_string, char *url)
+static int identify_image_type(image_t *image, const char *type_string, const char *url)
{
if (type_string)
{
@@ -669,7 +669,7 @@ static int image_mot_buffer_complete(image_t *image)
return ERROR_IMAGE_FORMAT_ERROR;
}
-int image_open(image_t *image, char *url, char *type_string)
+int image_open(image_t *image, const char *url, const char *type_string)
{
int retval = ERROR_OK;
diff --git a/src/target/image.h b/src/target/image.h
index 8b70b3b1..30240d56 100644
--- a/src/target/image.h
+++ b/src/target/image.h
@@ -100,7 +100,7 @@ typedef struct image_mot_s
uint8_t *buffer;
} image_mot_t;
-int image_open(image_t *image, char *url, char *type_string);
+int image_open(image_t *image, const char *url, const char *type_string);
int image_read_section(image_t *image, int section, uint32_t offset,
uint32_t size, uint8_t *buffer, uint32_t *size_read);
void image_close(image_t *image);
diff --git a/src/target/register.c b/src/target/register.c
index b9e7770f..58cc85e2 100644
--- a/src/target/register.c
+++ b/src/target/register.c
@@ -30,7 +30,8 @@
reg_arch_type_t *reg_arch_types = NULL;
-reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all)
+reg_t* register_get_by_name(reg_cache_t *first,
+ const char *name, bool search_all)
{
int i;
reg_cache_t *cache = first;
diff --git a/src/target/register.h b/src/target/register.h
index e7904e58..3af81cad 100644
--- a/src/target/register.h
+++ b/src/target/register.h
@@ -62,7 +62,8 @@ typedef struct reg_arch_type_s
struct reg_arch_type_s *next;
} reg_arch_type_t;
-reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all);
+reg_t* register_get_by_name(reg_cache_t *first,
+ const char *name, bool search_all);
reg_cache_t** register_get_last_cache_p(reg_cache_t **first);
int register_reg_arch_type(int (*get)(reg_t *reg),
diff --git a/src/target/target.c b/src/target/target.c
index 1bf680d1..575a99ce 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -2928,7 +2928,7 @@ static void writeString(FILE *f, char *s)
}
/* Dump a gmon.out histogram file. */
-static void writeGmon(uint32_t *samples, uint32_t sampleNum, char *filename)
+static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filename)
{
uint32_t i;
FILE *f = fopen(filename, "w");
diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c
index 17af9ead..909d7a1e 100644
--- a/src/xsvf/xsvf.c
+++ b/src/xsvf/xsvf.c
@@ -202,7 +202,6 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
int tdo_mismatch = 0;
int result;
int verbose = 1;
- char *filename;
bool collecting_path = false;
tap_state_t path[XSTATE_MAX_PATH];
@@ -226,7 +225,8 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
return ERROR_FAIL;
}
- filename = args[1]; /* we mess with args starting point below, snapshot filename here */
+ /* we mess with args starting point below, snapshot filename here */
+ const char *filename = args[1];
if (strcmp(args[0], "plain") != 0)
{