aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-30 23:57:30 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-30 23:57:30 +0000
commit58e31916def8db0e0b082b71d05c821428175bfd (patch)
tree9ba2d0680db36c49cba9669e9e74e4da5dcf8588
parent335fee3f36bd491197f8bd987baa6a7390f1750d (diff)
downloadriscv-openocd-58e31916def8db0e0b082b71d05c821428175bfd.zip
riscv-openocd-58e31916def8db0e0b082b71d05c821428175bfd.tar.gz
riscv-openocd-58e31916def8db0e0b082b71d05c821428175bfd.tar.bz2
Eliminate duplicated code in the handle_mw_command memory write loop.
- wordsize will always be 1, 2, or 4 due to preceeding switch statement. - move call to keep_alive after successful writes, not upon failures git-svn-id: svn://svn.berlios.de/openocd/trunk@1953 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/target/target.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 3921e82..95e7e5b 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1958,27 +1958,11 @@ static int handle_mw_command(struct command_context_s *cmd_ctx, char *cmd, char
}
for (i=0; i<count; i++)
{
- int retval;
- switch (wordsize)
- {
- case 4:
- retval = target->type->write_memory(target, address + i*wordsize, 4, 1, value_buf);
- break;
- case 2:
- retval = target->type->write_memory(target, address + i*wordsize, 2, 1, value_buf);
- break;
- case 1:
- retval = target->type->write_memory(target, address + i*wordsize, 1, 1, value_buf);
- break;
- default:
- return ERROR_OK;
- }
- keep_alive();
-
- if (retval!=ERROR_OK)
- {
+ int retval = target->type->write_memory(target,
+ address + i * wordsize, wordsize, 1, value_buf);
+ if (ERROR_OK != retval)
return retval;
- }
+ keep_alive();
}
return ERROR_OK;