summaryrefslogtreecommitdiff
path: root/src/flash/flash.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-05 13:27:50 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-05 13:27:50 +0000
commitf14f84ca1e5d4fbab00c52100859af5ec8226753 (patch)
tree0d4db762cafaac55623298495a96331bc040baf1 /src/flash/flash.c
parent6d95014674415e3b9ea9d46d5148d3410f96bbfd (diff)
downloadopenocd_libswd-f14f84ca1e5d4fbab00c52100859af5ec8226753.tar.gz
openocd_libswd-f14f84ca1e5d4fbab00c52100859af5ec8226753.tar.bz2
openocd_libswd-f14f84ca1e5d4fbab00c52100859af5ec8226753.tar.xz
openocd_libswd-f14f84ca1e5d4fbab00c52100859af5ec8226753.zip
Pavel Chromy: memory leak in at91sam7 flash driver, possible incorrect pointer conversion in gpnvm command handling,
uninitialized buffer issue in handle_flash_info_command in flash.c, some formatting. git-svn-id: svn://svn.berlios.de/openocd/trunk@446 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/flash.c')
-rw-r--r--src/flash/flash.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c
index 92ac6fd6..1c6773db 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -93,7 +93,7 @@ static int flash_driver_write(struct flash_bank_s *bank, u8 *buffer, u32 offset,
retval=bank->driver->write(bank, buffer, offset, count);
if (retval!=ERROR_OK)
{
- ERROR("error writing to flash at address 0x%08x at offset 0x%8.8x", bank->base, offset);
+ ERROR("error writing to flash at address 0x%08x at offset 0x%8.8x (%d)", bank->base, offset, retval);
}
return retval;
@@ -106,7 +106,7 @@ static int flash_driver_erase(struct flash_bank_s *bank, int first, int last)
retval=bank->driver->erase(bank, first, last);
if (retval!=ERROR_OK)
{
- ERROR("failed erasing sectors %d to %d", first, last);
+ ERROR("failed erasing sectors %d to %d (%d)", first, last, retval);
}
return retval;
@@ -119,7 +119,7 @@ int flash_driver_protect(struct flash_bank_s *bank, int set, int first, int last
retval=bank->driver->protect(bank, set, first, last);
if (retval!=ERROR_OK)
{
- ERROR("failed setting protection for areas %d to %d", first, last);
+ ERROR("failed setting protection for areas %d to %d (%d)", first, last, retval);
}
return retval;
@@ -311,6 +311,7 @@ int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cmd, char
flash_bank_t *p;
int i = 0;
int j = 0;
+ int retval;
if (argc != 1)
{
@@ -351,8 +352,11 @@ int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cmd, char
erase_state, protect_state);
}
- p->driver->info(p, buf, 1024);
+ *buf = '\0'; /* initialize buffer, otherwise it migh contain garbage if driver function fails */
+ retval = p->driver->info(p, buf, sizeof(buf));
command_print(cmd_ctx, "%s", buf);
+ if (retval != ERROR_OK)
+ ERROR("error retrieving flash info (%d)", retval);
}
}
@@ -918,7 +922,6 @@ int handle_flash_auto_erase_command(struct command_context_s *cmd_ctx, char *cmd
if (argc != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
-
}
if (strcmp(args[0], "on") == 0)