diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2023-05-06 10:34:13 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-05-18 10:18:42 +0000 |
commit | 3c2cc6efb8c9e892b2a1297ff3147c1d726a8937 (patch) | |
tree | b60166d42b06ce3619978a50776878752781e033 | |
parent | f20173a01f3eec286b2e2daac12834229cbfa3c8 (diff) | |
download | riscv-openocd-3c2cc6efb8c9e892b2a1297ff3147c1d726a8937.zip riscv-openocd-3c2cc6efb8c9e892b2a1297ff3147c1d726a8937.tar.gz riscv-openocd-3c2cc6efb8c9e892b2a1297ff3147c1d726a8937.tar.bz2 |
pld/virtex2: check error propagated by virtex2_read_stat()
Commit dd9137dc0e0c ("pld/virtex2: add missing error checks") adds
checks on the return value of several functions, allowing also
virtex2_read_stat() to propagate such returned values.
This triggers an error with clang, as it is now able to identify a
possible execution path that makes uninitialized the variable
status.
Check for the returned value of virtex2_read_stat() before using
the variable status and propagate the returned value.
While there, drop a useless empty string.
Change-Id: I7a23d3f904d4e07cdb6f6dfdf1179889b6b8afb8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7657
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
-rw-r--r-- | src/pld/virtex2.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 3c174ae..fd0725a 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -241,9 +241,13 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command) return ERROR_FAIL; } - virtex2_read_stat(device, &status); + int retval = virtex2_read_stat(device, &status); + if (retval != ERROR_OK) { + command_print(CMD, "cannot read virtex2 status register"); + return retval; + } - command_print(CMD, "virtex2 status register: 0x%8.8" PRIx32 "", status); + command_print(CMD, "virtex2 status register: 0x%8.8" PRIx32, status); return ERROR_OK; } |