From: Zach W. <zw...@us...> - 2009-11-17 00:54:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 (commit) via 69df712d1d06b2c698bed3de086b9f734de73b7e (commit) via 9763aef76a42fdaedcec9825fdf502f8cb7dd628 (commit) via df9b12695f4ede8144491d257ea236cdbca0a15c (commit) via 0a9daddc2e20d9ff5053a9faf3e1ec11fd600c73 (commit) via ccf59123b72b01149063d5864ef61077786c033e (commit) from 91ac164d95e1101120b938c684b78934d23dd51c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:44:53 2009 -0800 fileio: improve API types Use size_t instead of uint32_t when specifying file sizes. Update all consumers up through the layers to use size_t when required. These changes should be safe, but the higher-levels will need to be updated further to receive the intended benefits (i.e. large file support). Add error checking for fileio_read and file_write. Previously, all errors were being silently ignored, so this change might cause some problems for some people in some cases. However, it gives us the chance to handle any errors that do occur at higher-levels, rather than burying our heads in the sand. diff --git a/src/flash/ecos.c b/src/flash/ecos.c index c12ed9d..b2ffadf 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -152,8 +152,8 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command) static int loadDriver(struct ecosflash_flash_bank *info) { - uint32_t buf_cnt; - uint32_t image_size; + size_t buf_cnt; + size_t image_size; struct image image; image.base_address_set = 0; @@ -182,7 +182,8 @@ static int loadDriver(struct ecosflash_flash_bank *info) } target_write_buffer(target, image.sections[i].base_address, buf_cnt, buffer); image_size += buf_cnt; - LOG_DEBUG("%" PRIu32 " byte written at address 0x%8.8" PRIx32 "", buf_cnt, image.sections[i].base_address); + LOG_DEBUG("%zu bytes written at address 0x%8.8" PRIx32 "", + buf_cnt, image.sections[i].base_address); free(buffer); } diff --git a/src/flash/flash.c b/src/flash/flash.c index 03d4547..adc1411 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -811,7 +811,6 @@ COMMAND_HANDLER(handle_flash_write_bank_command) { uint32_t offset; uint8_t *buffer; - uint32_t buf_cnt; struct fileio fileio; if (argc != 3) @@ -833,6 +832,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) } buffer = malloc(fileio.size); + size_t buf_cnt; if (fileio_read(&fileio, fileio.size, buffer, &buf_cnt) != ERROR_OK) { free(buffer); @@ -1059,7 +1059,7 @@ static int flash_write_unlock(struct target *target, struct image *image, uint32 /* read sections to the buffer */ while (buffer_size < run_size) { - uint32_t size_read; + size_t size_read; size_read = run_size - buffer_size; if (size_read > image->sections[section].size - section_offset) diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index b80079d..dc91668 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -631,7 +631,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) return ret; } - uint32_t nwritten; + size_t nwritten; ret = fileio_write( &fileio, sizeof(customer), (const uint8_t *)customer, &nwritten ); if( ret != ERROR_OK ) @@ -755,7 +755,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) /* Page 4 */ uint32_t offset = ISS_CUSTOMER_START1 % FLASH_PAGE_SIZE; memset( page, 0xff, FLASH_PAGE_SIZE ); - uint32_t size_read; + size_t size_read; retval = image_read_section( &image, 0, 0, ISS_CUSTOMER_SIZE1, &page[offset], &size_read); if( retval != ERROR_OK ) diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 4356f27..0620642 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -705,7 +705,7 @@ static int mg_mflash_write(uint32_t addr, uint8_t *buff, uint32_t len) COMMAND_HANDLER(mg_write_cmd) { - uint32_t address, buf_cnt, cnt, res, i; + uint32_t address, cnt, res, i; uint8_t *buffer; struct fileio fileio; int ret; @@ -732,6 +732,7 @@ COMMAND_HANDLER(mg_write_cmd) struct duration bench; duration_start(&bench); + size_t buf_cnt; for (i = 0; i < cnt; i++) { if ((ret = fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt)) != ERROR_OK) @@ -769,7 +770,7 @@ mg_write_cmd_err: COMMAND_HANDLER(mg_dump_cmd) { - uint32_t address, size_written, size, cnt, res, i; + uint32_t address, size, cnt, res, i; uint8_t *buffer; struct fileio fileio; int ret; @@ -797,6 +798,7 @@ COMMAND_HANDLER(mg_dump_cmd) struct duration bench; duration_start(&bench); + size_t size_written; for (i = 0; i < cnt; i++) { if ((ret = mg_mflash_read(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK) goto mg_dump_cmd_err; diff --git a/src/flash/nand.c b/src/flash/nand.c index 9d997fa..71a67c4 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1453,8 +1453,8 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, static int nand_fileio_read(struct nand_device *nand, struct nand_fileio_state *s) { - uint32_t total_read = 0; - uint32_t one_read; + size_t total_read = 0; + size_t one_read; if (NULL != s->page) { @@ -1616,7 +1616,7 @@ COMMAND_HANDLER(handle_nand_dump_command) while (s.size > 0) { - uint32_t size_written; + size_t size_written; int retval = nand_read_page(nand, s.address / nand->page_size, s.page, s.page_size, s.oob, s.oob_size); if (ERROR_OK != retval) diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 84d46bd..8f2ce22 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -143,7 +143,7 @@ int fileio_close(struct fileio *fileio) return retval; } -int fileio_seek(struct fileio *fileio, uint32_t position) +int fileio_seek(struct fileio *fileio, size_t position) { int retval; if ((retval = fseek(fileio->file, position, SEEK_SET)) != 0) @@ -155,14 +155,16 @@ int fileio_seek(struct fileio *fileio, uint32_t position) return ERROR_OK; } -static inline int fileio_local_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read) +static int fileio_local_read(struct fileio *fileio, + size_t size, void *buffer, size_t *size_read) { - *size_read = fread(buffer, 1, size, fileio->file); - - return ERROR_OK; + ssize_t retval = fread(buffer, 1, size, fileio->file); + *size_read = (retval >= 0) ? retval : 0; + return (retval < 0) ? retval : ERROR_OK; } -int fileio_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read) +int fileio_read(struct fileio *fileio, size_t size, void *buffer, + size_t *size_read) { return fileio_local_read(fileio, size, buffer, size_read); } @@ -170,17 +172,17 @@ int fileio_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t int fileio_read_u32(struct fileio *fileio, uint32_t *data) { uint8_t buf[4]; - uint32_t size_read; - int retval; - - if ((retval = fileio_local_read(fileio, 4, buf, &size_read)) != ERROR_OK) - return retval; - *data = be_to_h_u32(buf); - - return ERROR_OK; + size_t size_read; + int retval = fileio_local_read(fileio, sizeof(uint32_t), buf, &size_read); + if (ERROR_OK == retval && sizeof(uint32_t) != size_read) + retval = -EIO; + if (ERROR_OK == retval) + *data = be_to_h_u32(buf); + return retval; } -static inline int fileio_local_fgets(struct fileio *fileio, uint32_t size, char *buffer) +static int fileio_local_fgets(struct fileio *fileio, + size_t size, void *buffer) { if (fgets(buffer, size, fileio->file) == NULL) return ERROR_FILEIO_OPERATION_FAILED; @@ -188,40 +190,37 @@ static inline int fileio_local_fgets(struct fileio *fileio, uint32_t size, char return ERROR_OK; } -int fileio_fgets(struct fileio *fileio, uint32_t size, char *buffer) +int fileio_fgets(struct fileio *fileio, size_t size, void *buffer) { return fileio_local_fgets(fileio, size, buffer); } -static inline int fileio_local_write(struct fileio *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written) +static int fileio_local_write(struct fileio *fileio, + size_t size, const void *buffer, size_t *size_written) { - *size_written = fwrite(buffer, 1, size, fileio->file); - - return ERROR_OK; + ssize_t retval = fwrite(buffer, 1, size, fileio->file); + *size_written = (retval >= 0) ? retval : 0; + return (retval < 0) ? retval : ERROR_OK; } -int fileio_write(struct fileio *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written) +int fileio_write(struct fileio *fileio, + size_t size, const void *buffer, size_t *size_written) { - int retval; - - retval = fileio_local_write(fileio, size, buffer, size_written); - + int retval = fileio_local_write(fileio, size, buffer, size_written); if (retval == ERROR_OK) fileio->size += *size_written; - - return retval;; + return retval; } int fileio_write_u32(struct fileio *fileio, uint32_t data) { uint8_t buf[4]; - uint32_t size_written; - int retval; - h_u32_to_be(buf, data); - if ((retval = fileio_local_write(fileio, 4, buf, &size_written)) != ERROR_OK) - return retval; + size_t size_written; + int retval = fileio_write(fileio, 4, buf, &size_written); + if (ERROR_OK == retval && size_written != sizeof(uint32_t)) + retval = -EIO; - return ERROR_OK; + return retval; } diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 6ed6fe4..325b441 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -58,13 +58,13 @@ int fileio_open(struct fileio *fileio, const char *url, enum fileio_access access, enum fileio_type type); int fileio_close(struct fileio *fileio); -int fileio_seek(struct fileio *fileio, uint32_t position); -int fileio_fgets(struct fileio *fileio, uint32_t size, char *buffer); +int fileio_seek(struct fileio *fileio, size_t position); +int fileio_fgets(struct fileio *fileio, size_t size, void *buffer); int fileio_read(struct fileio *fileio, - uint32_t size, uint8_t *buffer, uint32_t *size_read); + size_t size, void *buffer, size_t *size_read); int fileio_write(struct fileio *fileio, - uint32_t size, const uint8_t *buffer, uint32_t *size_written); + size_t size, const void *buffer, size_t *size_written); int fileio_read_u32(struct fileio *fileio, uint32_t *data); int fileio_write_u32(struct fileio *fileio, uint32_t data); diff --git a/src/target/etm.c b/src/target/etm.c index 5a0ffed..fa7a71b 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -640,7 +640,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction { int i; int section = -1; - uint32_t size_read; + size_t size_read; uint32_t opcode; int retval; diff --git a/src/target/image.c b/src/target/image.c index bba4675..8774c25 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -48,7 +48,7 @@ static int autodetect_image_type(struct image *image, const char *url) { int retval; struct fileio fileio; - uint32_t read_bytes; + size_t read_bytes; uint8_t buffer[9]; /* read the first 4 bytes of image */ @@ -175,7 +175,7 @@ static int image_ihex_buffer_complete(struct image *image) uint32_t record_type; uint32_t checksum; uint8_t cal_checksum = 0; - uint32_t bytes_read = 0; + size_t bytes_read = 0; if (sscanf(&lpszLine[bytes_read], ":%2" SCNx32 "%4" SCNx32 "%2" SCNx32 , &count, &address, &record_type) != 3) { @@ -360,7 +360,7 @@ static int image_ihex_buffer_complete(struct image *image) static int image_elf_read_headers(struct image *image) { struct image_elf *elf = image->type_private; - uint32_t read_bytes; + size_t read_bytes; uint32_t i,j; int retval; @@ -458,11 +458,11 @@ static int image_elf_read_headers(struct image *image) return ERROR_OK; } -static int image_elf_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, uint32_t *size_read) +static int image_elf_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, size_t *size_read) { struct image_elf *elf = image->type_private; Elf32_Phdr *segment = (Elf32_Phdr *)image->sections[section].private; - uint32_t read_size,really_read; + size_t read_size,really_read; int retval; *size_read = 0; @@ -474,7 +474,7 @@ static int image_elf_read_section(struct image *image, int section, uint32_t off { /* maximal size present in file for the current segment */ read_size = MIN(size, field32(elf,segment->p_filesz)-offset); - LOG_DEBUG("read elf: size = 0x%" PRIx32 " at 0x%" PRIx32 "",read_size, + LOG_DEBUG("read elf: size = 0x%zu at 0x%" PRIx32 "", read_size, field32(elf,segment->p_offset) + offset); /* read initialized area of the segment */ if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset) + offset)) != ERROR_OK) @@ -797,7 +797,7 @@ int image_open(struct image *image, const char *url, const char *type_string) return retval; }; -int image_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, uint32_t *size_read) +int image_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, size_t *size_read) { int retval; diff --git a/src/target/image.h b/src/target/image.h index 06d47bf..0dac5ba 100644 --- a/src/target/image.h +++ b/src/target/image.h @@ -102,7 +102,7 @@ struct image_mot int image_open(struct image *image, const char *url, const char *type_string); int image_read_section(struct image *image, int section, uint32_t offset, - uint32_t size, uint8_t *buffer, uint32_t *size_read); + uint32_t size, uint8_t *buffer, size_t *size_read); void image_close(struct image *image); int image_add_section(struct image *image, uint32_t base, uint32_t size, diff --git a/src/target/target.c b/src/target/target.c index f141e93..c00c2ed 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2399,7 +2399,7 @@ static COMMAND_HELPER(parse_load_image_command_args, struct image *image, COMMAND_HANDLER(handle_load_image_command) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; uint32_t min_address = 0; uint32_t max_address = 0xffffffff; @@ -2519,7 +2519,7 @@ COMMAND_HANDLER(handle_dump_image_command) int retval = ERROR_OK; while (size > 0) { - uint32_t size_written; + size_t size_written; uint32_t this_run_size = (size > 560) ? 560 : size; retval = target_read_buffer(target, address, this_run_size, buffer); if (retval != ERROR_OK) @@ -2553,7 +2553,7 @@ COMMAND_HANDLER(handle_dump_image_command) static COMMAND_HELPER(handle_verify_image_command_internal, int verify) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; int i; int retval; @@ -2674,7 +2674,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify) } } else { - command_print(cmd_ctx, "address 0x%08" PRIx32 " length 0x%08" PRIx32 "", + command_print(cmd_ctx, "address 0x%08" PRIx32 " length 0x%08zx", image.sections[i].base_address, buf_cnt); } @@ -4537,7 +4537,7 @@ static void free_fastload(void) COMMAND_HANDLER(handle_fast_load_image_command) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; uint32_t min_address = 0; uint32_t max_address = 0xffffffff; diff --git a/src/target/xscale.c b/src/target/xscale.c index 30ca3bf..9e93c02 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -2557,7 +2557,7 @@ static int xscale_read_instruction(struct target *target, struct xscale_common *xscale = target_to_xscale(target); int i; int section = -1; - uint32_t size_read; + size_t size_read; uint32_t opcode; int retval; commit 69df712d1d06b2c698bed3de086b9f734de73b7e Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:22:21 2009 -0800 struct fileio: improve member types Add const keyword to file url and cast to free(). Make size an ssize_t and chase all format strings that use it. diff --git a/src/flash/flash.c b/src/flash/flash.c index bdee53b..03d4547 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -847,7 +847,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "wrote %lld byte from file %s to flash bank %u" + command_print(cmd_ctx, "wrote %zu byte from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", fileio.size, args[1], p->bank_number, offset, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 49dc432..4356f27 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -750,7 +750,7 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { - command_print(cmd_ctx, "wrote %lli byte from file %s " + command_print(cmd_ctx, "wrote %zu byte from file %s " "in %fs (%0.3f kB/s)", fileio.size, args[1], duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } diff --git a/src/flash/nand.c b/src/flash/nand.c index fba8104..9d997fa 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1637,7 +1637,7 @@ COMMAND_HANDLER(handle_nand_dump_command) if (nand_fileio_finish(&s) == ERROR_OK) { - command_print(cmd_ctx, "dumped %lld byte in %fs (%0.3f kb/s)", + command_print(cmd_ctx, "dumped %zu bytes in %fs (%0.3f kb/s)", s.fileio.size, duration_elapsed(&s.bench), duration_kbps(&s.bench, s.fileio.size)); } diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 71cae75..84d46bd 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -137,7 +137,7 @@ int fileio_close(struct fileio *fileio) retval = fileio_close_local(fileio); - free(fileio->url); + free((void*)fileio->url); fileio->url = NULL; return retval; diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 8cba926..6ed6fe4 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -47,8 +47,8 @@ enum fileio_access }; struct fileio { - char *url; - long long size; + const char *url; + ssize_t size; enum fileio_type type; enum fileio_access access; FILE *file; diff --git a/src/target/target.c b/src/target/target.c index c24085f..f141e93 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2543,7 +2543,7 @@ COMMAND_HANDLER(handle_dump_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(cmd_ctx, - "dumped %lld bytes in %fs (%0.3f kb/s)", fileio.size, + "dumped %zu bytes in %fs (%0.3f kb/s)", fileio.size, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } commit 9763aef76a42fdaedcec9825fdf502f8cb7dd628 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 03:42:45 2009 -0800 helper/log: improve API parameter types Uses unsigned type to pass line numbers. Use uint64_t to pass sleep routines their milliseconds. Updates sleep routines to use this type and improve whitespace. diff --git a/src/helper/log.c b/src/helper/log.c index 5a65c87..9396ffe 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -77,7 +77,7 @@ struct store_log_forward }; /* either forward the log to the listeners or store it for possible forwarding later */ -static void log_forward(const char *file, int line, const char *function, const char *string) +static void log_forward(const char *file, unsigned line, const char *function, const char *string) { if (log_forward_count==0) { @@ -224,7 +224,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch } -void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) +void log_printf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) { char *string; va_list ap; @@ -245,7 +245,7 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f va_end(ap); } -void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) +void log_printf_lf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) { char *string; va_list ap; @@ -504,27 +504,24 @@ void kept_alive() } /* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */ -void alive_sleep(int ms) +void alive_sleep(uint64_t ms) { - int i; - int napTime = 10; - for (i = 0; i < ms; i += napTime) + uint64_t napTime = 10; + for (uint64_t i = 0; i < ms; i += napTime) { - int sleep_a_bit = ms-i; + uint64_t sleep_a_bit = ms - i; if (sleep_a_bit > napTime) - { sleep_a_bit = napTime; - } - usleep(sleep_a_bit*1000); + + usleep(sleep_a_bit * 1000); keep_alive(); } } -void busy_sleep(int ms) +void busy_sleep(uint64_t ms) { - long long then; - then = timeval_ms(); - while ((timeval_ms()-then) < ms) + uint64_t then = timeval_ms(); + while (timeval_ms() - then < ms) { /* busy wait */ } diff --git a/src/helper/log.h b/src/helper/log.h index 3bf9840..6f7c24a 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -59,10 +59,10 @@ enum log_levels LOG_LVL_DEBUG = 3 }; -void log_printf(enum log_levels level, const char *file, int line, +void log_printf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); -void log_printf_lf(enum log_levels level, const char *file, int line, +void log_printf_lf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); @@ -74,8 +74,8 @@ int log_register_commands(struct command_context *cmd_ctx); void keep_alive(void); void kept_alive(void); -void alive_sleep(int ms); -void busy_sleep(int ms); +void alive_sleep(uint64_t ms); +void busy_sleep(uint64_t ms); /* log entries can be paused and replayed roughly according to the try/catch/rethrow * concepts in C++ commit df9b12695f4ede8144491d257ea236cdbca0a15c Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 04:05:33 2009 -0800 use Jim_CmdProc in jim_register The jim_register command just needed to use the type defined by jim.h. diff --git a/src/helper/command.c b/src/helper/command.c index 41af035..7edd585 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -869,7 +869,8 @@ void process_jim_events(void) #endif } -void register_jim(struct command_context *cmd_ctx, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help) +void register_jim(struct command_context *cmd_ctx, const char *name, + Jim_CmdProc cmd, const char *help) { Jim_CreateCommand(interp, name, cmd, NULL, NULL); diff --git a/src/helper/command.h b/src/helper/command.h index 94d9816..79e57f5 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -190,7 +190,8 @@ extern int fast_and_dangerous; extern Jim_Interp *interp; -void register_jim(struct command_context *context, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help); +void register_jim(struct command_context *context, const char *name, + Jim_CmdProc cmd, const char *help); long jim_global_long(const char *variable); commit 0a9daddc2e20d9ff5053a9faf3e1ec11fd600c73 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:21:56 2009 -0800 improve constness of open_file_from_path diff --git a/src/helper/configuration.c b/src/helper/configuration.c index 1f7240d..74bcc9b 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -86,7 +86,7 @@ char *find_file(const char *file) return NULL; } -FILE *open_file_from_path (char *file, char *mode) +FILE *open_file_from_path(const char *file, const char *mode) { if (mode[0]!='r') { diff --git a/src/helper/configuration.h b/src/helper/configuration.h index 9b77a25..ce9159c 100644 --- a/src/helper/configuration.h +++ b/src/helper/configuration.h @@ -36,7 +36,7 @@ void add_script_search_dir(const char *dir); int configuration_output_handler(struct command_context *cmd_ctx, const char *line); -FILE *open_file_from_path(char *file, char *mode); +FILE *open_file_from_path(const char *file, const char *mode); char *find_file(const char *name); commit ccf59123b72b01149063d5864ef61077786c033e Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 03:53:19 2009 -0800 make command line options const The getopt_long call allows a const struct option, so mark ours const too. diff --git a/src/helper/options.c b/src/helper/options.c index e26782f..874196e 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -32,7 +32,7 @@ static int help_flag, version_flag; -static struct option long_options[] = +static const struct option long_options[] = { {"help", no_argument, &help_flag, 1}, {"version", no_argument, &version_flag, 1}, ----------------------------------------------------------------------- Summary of changes: src/flash/ecos.c | 7 ++-- src/flash/flash.c | 6 ++-- src/flash/lpc2900.c | 4 +- src/flash/mflash.c | 8 +++-- src/flash/nand.c | 8 ++-- src/helper/command.c | 3 +- src/helper/command.h | 3 +- src/helper/configuration.c | 2 +- src/helper/configuration.h | 2 +- src/helper/fileio.c | 67 +++++++++++++++++++++---------------------- src/helper/fileio.h | 12 ++++---- src/helper/log.c | 27 ++++++++---------- src/helper/log.h | 8 ++-- src/helper/options.c | 2 +- src/target/etm.c | 2 +- src/target/image.c | 14 ++++---- src/target/image.h | 2 +- src/target/target.c | 12 ++++---- src/target/xscale.c | 2 +- 19 files changed, 96 insertions(+), 95 deletions(-) hooks/post-receive -- Main OpenOCD repository |