From 3c2cc6efb8c9e892b2a1297ff3147c1d726a8937 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 6 May 2023 10:34:13 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.openocd.org/c/openocd/+/7657 Reviewed-by: Daniel Anselmi Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/pld/virtex2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 3c174ae59..fd0725a63 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; }