diff options
author | Paul Fertser <fercerpav@gmail.com> | 2018-01-13 17:15:29 +0300 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2018-03-13 08:42:17 +0000 |
commit | 6e76e56e2e34b78e4f0fad4238c2de85b1983305 (patch) | |
tree | fba555cc65af5fed4cff3114aad2238b9d41bb51 /src/target/hla_target.c | |
parent | a957a1c8433f45452902de3060364122602e6e1c (diff) | |
download | riscv-openocd-6e76e56e2e34b78e4f0fad4238c2de85b1983305.zip riscv-openocd-6e76e56e2e34b78e4f0fad4238c2de85b1983305.tar.gz riscv-openocd-6e76e56e2e34b78e4f0fad4238c2de85b1983305.tar.bz2 |
target: hla: check return value of hl_dcc_read
This should fix "Assigned value is garbage or undefined" warning
reported by clang:
http://build.openocd.org/job/openocd-clang/doclinks/1/report-391318.html
Change-Id: Ib9488fadca871814328501e415f88822291e0c96
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4332
Tested-by: jenkins
Diffstat (limited to 'src/target/hla_target.c')
-rw-r--r-- | src/target/hla_target.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/target/hla_target.c b/src/target/hla_target.c index a3e6835..ba88248 100644 --- a/src/target/hla_target.c +++ b/src/target/hla_target.c @@ -271,7 +271,10 @@ static int hl_target_request_data(struct target *target, uint32_t i; for (i = 0; i < (size * 4); i++) { - hl_dcc_read(hl_if, &data, &ctrl); + int err = hl_dcc_read(hl_if, &data, &ctrl); + if (err != ERROR_OK) + return err; + buffer[i] = data; } @@ -281,6 +284,8 @@ static int hl_target_request_data(struct target *target, static int hl_handle_target_request(void *priv) { struct target *target = priv; + int err; + if (!target_was_examined(target)) return ERROR_OK; struct hl_interface_s *hl_if = target_to_adapter(target); @@ -292,7 +297,9 @@ static int hl_handle_target_request(void *priv) uint8_t data; uint8_t ctrl; - hl_dcc_read(hl_if, &data, &ctrl); + err = hl_dcc_read(hl_if, &data, &ctrl); + if (err != ERROR_OK) + return err; /* check if we have data */ if (ctrl & (1 << 0)) { @@ -300,11 +307,20 @@ static int hl_handle_target_request(void *priv) /* we assume target is quick enough */ request = data; - hl_dcc_read(hl_if, &data, &ctrl); + err = hl_dcc_read(hl_if, &data, &ctrl); + if (err != ERROR_OK) + return err; + request |= (data << 8); - hl_dcc_read(hl_if, &data, &ctrl); + err = hl_dcc_read(hl_if, &data, &ctrl); + if (err != ERROR_OK) + return err; + request |= (data << 16); - hl_dcc_read(hl_if, &data, &ctrl); + err = hl_dcc_read(hl_if, &data, &ctrl); + if (err != ERROR_OK) + return err; + request |= (data << 24); target_request(target, request); } |