diff options
author | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-05-06 23:05:57 +0000 |
---|---|---|
committer | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-05-06 23:05:57 +0000 |
commit | 8cbb2ae7f48ab0c80b7ab644c01fb49e75a6959e (patch) | |
tree | aad1e42ff534a2b1ee2a932d787350761c655f16 /src/svf | |
parent | 5c1cb131e91b4e23aa637b5fea7df6d1b850bd6e (diff) | |
download | openocd+libswd-8cbb2ae7f48ab0c80b7ab644c01fb49e75a6959e.tar.gz openocd+libswd-8cbb2ae7f48ab0c80b7ab644c01fb49e75a6959e.tar.bz2 openocd+libswd-8cbb2ae7f48ab0c80b7ab644c01fb49e75a6959e.tar.xz openocd+libswd-8cbb2ae7f48ab0c80b7ab644c01fb49e75a6959e.zip |
Fix pointer cast alignment issues in svf.c
git-svn-id: svn://svn.berlios.de/openocd/trunk@1622 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/svf')
-rw-r--r-- | src/svf/svf.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c index 00e88361..c94461ca 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -653,11 +653,17 @@ static int svf_check_tdo(void) { if ((svf_tdi_buffer[index + j] & svf_mask_buffer[index + j]) != svf_tdo_buffer[index + j]) { - LOG_ERROR("tdo check error at line %d, read = 0x%X, want = 0x%X, mask = 0x%X", + unsigned bitmask = (1 << svf_check_tdo_para[i].bit_len) - 1; + unsigned received, expected, tapmask; + memcpy(&received, svf_tdi_buffer + index, sizeof(unsigned)); + memcpy(&expected, svf_tdo_buffer + index, sizeof(unsigned)); + memcpy(&tapmask, svf_mask_buffer + index, sizeof(unsigned)); + LOG_ERROR("tdo check error at line %d, " + "read = 0x%X, want = 0x%X, mask = 0x%X", svf_check_tdo_para[i].line_num, - (*(int*)(svf_tdi_buffer + index)) & ((1 << svf_check_tdo_para[i].bit_len) - 1), - (*(int*)(svf_tdo_buffer + index)) & ((1 << svf_check_tdo_para[i].bit_len) - 1), - (*(int*)(svf_mask_buffer + index)) & ((1 << svf_check_tdo_para[i].bit_len) - 1)); + received & bitmask, + expected & bitmask, + tapmask & bitmask); return ERROR_FAIL; } } @@ -1381,8 +1387,11 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str) // output debug info if ((SIR == command) || (SDR == command)) { + int read_value; + memcpy(&read_value, svf_tdi_buffer, sizeof(int)); // in debug mode, data is from index 0 - LOG_DEBUG("\tTDO read = 0x%X", (*(int*)svf_tdi_buffer) & ((1 << (svf_check_tdo_para[0].bit_len)) - 1)); + int read_mask = (1 << (svf_check_tdo_para[0].bit_len)) - 1; + LOG_DEBUG("\tTDO read = 0x%X", read_value & read_mask); } } } |