This is an automated email from Gerrit.

Xiang W (wxj...@126.com) just uploaded a new patch set to Gerrit, which you can 
find at http://openocd.zylin.com/6265

-- gerrit

commit 6521a8f23c4d7258d795be5e5b448c6cf5a3f292
Author: Xiang W <wxj...@126.com>
Date:   Tue May 18 20:39:41 2021 +0800

    riscv: Add assert for debug buffer
    
    The current debug buffer uses a fixed maximum length, and the new version of
    the debugging protocol may be changed in the future. Here, add assert for
    error detection.
    
    Change-Id: I7187b489173b8b74e8483a892dbc9a46edf46157
    Signed-off-by: Xiang W <wxj...@126.com>

diff --git a/src/target/riscv/program.c b/src/target/riscv/program.c
index 8e2ce5d..c043ee3 100644
--- a/src/target/riscv/program.c
+++ b/src/target/riscv/program.c
@@ -23,6 +23,7 @@ int riscv_program_init(struct riscv_program *p, struct target 
*target)
        for (size_t i = 0; i < RISCV_REGISTER_COUNT; ++i)
                p->writes_xreg[i] = 0;
 
+       assert(RISCV_MAX_DEBUG_BUFFER_SIZE >= riscv_debug_buffer_size(target));
        for (size_t i = 0; i < RISCV_MAX_DEBUG_BUFFER_SIZE; ++i)
                p->debug_buffer[i] = -1;
 

-- 

Reply via email to