aboutsummaryrefslogtreecommitdiff
path: root/src/flash/mflash.c
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-13 14:44:53 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-16 15:47:09 -0800
commit51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 (patch)
tree78cb65e732581369d51937ca7ba1de670313f016 /src/flash/mflash.c
parent69df712d1d06b2c698bed3de086b9f734de73b7e (diff)
downloadriscv-openocd-51862bb98c26e9b3f03d46ae0f8ceb434f0743d0.zip
riscv-openocd-51862bb98c26e9b3f03d46ae0f8ceb434f0743d0.tar.gz
riscv-openocd-51862bb98c26e9b3f03d46ae0f8ceb434f0743d0.tar.bz2
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.
Diffstat (limited to 'src/flash/mflash.c')
-rw-r--r--src/flash/mflash.c6
1 files changed, 4 insertions, 2 deletions
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;