This is an automated email from Gerrit. "Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7204
-- gerrit commit ec2b158fc781a24a5888f309639560ef4000fd16 Author: Antonio Borneo <borneo.anto...@gmail.com> Date: Mon Sep 19 14:22:02 2022 +0200 target/armv4_5: fix scan-build error Issue detected offline with clang version 14.0.6, not available in https://build.openocd.org/job/openocd-clang/ The value returned by arm_mode_to_number() is used as index for the array in macro ARMV4_5_CORE_REG_MODE(). The returned negative value cause scan-build to trigger: Logic error: Array subscript is undefined armv4_5.c:1357 Array subscript is undefined We already use LOG_ERROR() and we never got it reported, not got a crash for the negative value returned. Looks safe to silence clang by returning a valid value and keeping the LOG_ERROR(). Add also a TODO for a potential future addition of abort(). Change-Id: I083dfae2c5bd62e215a24b1da41c05dc5979b201 Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 48af5035a0..c111dce7ee 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -215,7 +215,8 @@ int arm_mode_to_number(enum arm_mode mode) return 8; default: LOG_ERROR("invalid mode value encountered %d", mode); - return -1; + /* map invalid to user mode. TODO: Use abort() ? */ + return 0; } } --