This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f8749ef0e0 arch/risc-v: guard tcb->name usage
f8749ef0e0 is described below

commit f8749ef0e0448632f594fabf5aca126747a2d1f6
Author: Yanfeng Liu <[email protected]>
AuthorDate: Wed May 22 14:52:42 2024 +0800

    arch/risc-v: guard tcb->name usage
    
    Add guard for tcb->name field usage as it is not always available.
    
    Signed-off-by: Yanfeng Liu <[email protected]>
---
 arch/risc-v/src/common/riscv_exception.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/risc-v/src/common/riscv_exception.c 
b/arch/risc-v/src/common/riscv_exception.c
index d3050840d4..68c34a0ad1 100644
--- a/arch/risc-v/src/common/riscv_exception.c
+++ b/arch/risc-v/src/common/riscv_exception.c
@@ -94,7 +94,11 @@ int riscv_exception(int mcause, void *regs, void *args)
 #ifdef CONFIG_ARCH_KERNEL_STACK
   if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
     {
+#  if CONFIG_TASK_NAME_SIZE > 0
       _alert("Segmentation fault in PID %d: %s\n", tcb->pid, tcb->name);
+#  else
+      _alert("Segmentation fault in PID %d\n", tcb->pid);
+#  endif
 
       tcb->flags |= TCB_FLAG_FORCED_CANCEL;
 

Reply via email to