|
From: OpenOCD-Gerrit <ope...@us...> - 2022-11-11 20:11:33
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 0946e80407150b68acd02bc59f0f3a3170142c4c (commit)
from 7a09635735486dd2d74576b003c85c7ff16705d5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0946e80407150b68acd02bc59f0f3a3170142c4c
Author: Antonio Borneo <bor...@gm...>
Date: Wed Nov 2 00:57:17 2022 +0100
esirisc_jtag: fix clang error core.VLASize
The function esirisc_jtag_recv() can be called with argument
num_in_fields = 0, for example as consequence of calling
esirisc_jtag_continue().
In this case, num_in_bytes is zero and the allocation of the
variable-length array 'r' requires size zero.
src/target/esirisc_jtag.c:133:2: warning: Declared variable-length
array (VLA) has zero size [core.VLASize]
uint8_t r[num_in_bytes * 2];
^~~~~~~~~ ~~~~~~~~~~~~~~~~
Fix it by forcing size one when num_in_bytes is zero.
Change-Id: Id764c7b5ec4f5b3c18c7da650bbff39fc98ed049
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/7301
Tested-by: jenkins
diff --git a/src/target/esirisc_jtag.c b/src/target/esirisc_jtag.c
index 54abc4003..1ec1726e5 100644
--- a/src/target/esirisc_jtag.c
+++ b/src/target/esirisc_jtag.c
@@ -130,7 +130,9 @@ static int esirisc_jtag_recv(struct esirisc_jtag *jtag_info,
int num_in_bytes = DIV_ROUND_UP(num_in_bits, 8);
struct scan_field fields[3];
- uint8_t r[num_in_bytes * 2];
+ /* prevent zero-size variable length array */
+ int r_size = num_in_bytes ? num_in_bytes * 2 : 1;
+ uint8_t r[r_size];
esirisc_jtag_set_instr(jtag_info, INSTR_DEBUG);
-----------------------------------------------------------------------
Summary of changes:
src/target/esirisc_jtag.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|