Skip to contentSkip to conversation

xen/arm: traps: Fix MISRA C 2012 Rule 8.4 violation

PATCH In review Xenia Ragiadakou 3 participants 4 messages Jul 5, 2022 – Jul 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: traps: Fix MISRA C 2012 Rule 8.4 violation

Add the function prototype of show_stack() in <asm/processor.h> header file so that it is visible before its definition in traps.c.

Although show_stack() is referenced only in traps.c, it is declared with external linkage because, during development, it is often called also by other files for debugging purposes. Declaring it static would increase development effort. Add appropriate comment

---
 xen/arch/arm/include/asm/processor.h | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/include/asm/processor.h +2 -0
index 4188ec6bfb..c021160412 100644
@@ -558,7 +558,9 @@ extern register_t __cpu_logical_map[];
 void panic_PAR(uint64_t par);
 
 void show_execution_state(const struct cpu_user_regs *regs);
+/* Debugging functions are declared with external linkage to aid development. */
 void show_registers(const struct cpu_user_regs *regs);
+void show_stack(const struct cpu_user_regs *regs);
 //#define dump_execution_state() run_in_exception_handler(show_execution_state)
 #define dump_execution_state() WARN()
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Xenia,

Quoted 11 lines · Xenia Ragiadakou

Add the function prototype of show_stack() in <asm/processor.h> header file so that it is visible before its definition in traps.c.

Although show_stack() is referenced only in traps.c, it is declared with external linkage because, during development, it is often called also by other files for debugging purposes. Declaring it static would increase development effort. Add appropriate comment

Cheers
Bertrand

Quoted 21 lines

---
xen/arch/arm/include/asm/processor.h | 2 ++

1 file changed, 2 insertions(+)
xen/arch/arm/include/asm/processor.h +2 -0
index 4188ec6bfb..c021160412 100644
@@ -558,7 +558,9 @@ extern register_t __cpu_logical_map[];
 void panic_PAR(uint64_t par);
 
 void show_execution_state(const struct cpu_user_regs *regs);
+/* Debugging functions are declared with external linkage to aid development. */
 void show_registers(const struct cpu_user_regs *regs);
+void show_stack(const struct cpu_user_regs *regs);
 //#define dump_execution_state() run_in_exception_handler(show_execution_state)
 #define dump_execution_state() WARN()
 
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#2 lore raw
In reply to Xenia Ragiadakou

Hi Xenia,

Quoted 9 lines · Xenia Ragiadakou

Add the function prototype of show_stack() in <asm/processor.h> header file so that it is visible before its definition in traps.c.

Although show_stack() is referenced only in traps.c, it is declared with external linkage because, during development, it is often called also by other files for debugging purposes. Declaring it static would increase development effort. Add appropriate comment

With one request below:

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 561

Quoted 13 lines
---
  xen/arch/arm/include/asm/processor.h | 2 ++
  1 file changed, 2 insertions(+)
xen/arch/arm/include/asm/processor.h +1 -0
index 4188ec6bfb..c021160412 100644
@@ -558,7 +558,9 @@ extern register_t __cpu_logical_map[];
  void panic_PAR(uint64_t par);
 
  void show_execution_state(const struct cpu_user_regs *regs);
+/* Debugging functions are declared with external linkage to aid development. */

I agree that those functions are only used for debugging today. But there are no reason they can't be used in code in the future. So I would like this comment to be dropped because it could easily become stale.

If the others argue for keeping it, then I think...

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 563

Quoted 2 lines
xen/arch/arm/include/asm/processor.h +1 -0
  void show_registers(const struct cpu_user_regs *regs);
+void show_stack(const struct cpu_user_regs *regs);

... we need a newline here so it is clearer which set of functions you are referring to (at the moment one may think that dump_execution_state()) is also included.

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 566

Quoted 3 lines
xen/arch/arm/include/asm/processor.h +0 -0
  //#define dump_execution_state() run_in_exception_handler(show_execution_state)
  #define dump_execution_state() WARN()
 

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw

Hi Julien,

Quoted 17 lines · Julien Grall

Hi Xenia,

Quoted 7 lines · Xenia Ragiadakou

Add the function prototype of show_stack() in <asm/processor.h> header file so that it is visible before its definition in traps.c. Although show_stack() is referenced only in traps.c, it is declared with external linkage because, during development, it is often called also by other files for debugging purposes. Declaring it static would increase development effort. Add appropriate comment

With one request below:

Quoted 14 lines

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 560

Quoted 11 lines
---
 xen/arch/arm/include/asm/processor.h | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/include/asm/processor.h +1 -0
index 4188ec6bfb..c021160412 100644
@@ -558,7 +558,9 @@ extern register_t __cpu_logical_map[];
 void panic_PAR(uint64_t par);
   void show_execution_state(const struct cpu_user_regs *regs);
+/* Debugging functions are declared with external linkage to aid development. */

I agree that those functions are only used for debugging today. But there are no reason they can't be used in code in the future. So I would like this comment to be dropped because it could easily become stale.

I think if someone is one day using this somewhere else then he should remove the comment but in the current state the comment would be useful so that the next one going through Misra violations is not trying to fix it.

In the mid-term, if we have a standard way to document violations then the comment should be replaced by it.

Quoted 7 lines

If the others argue for keeping it, then I think...

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 563

Quoted 2 lines
xen/arch/arm/include/asm/processor.h +1 -0
 void show_registers(const struct cpu_user_regs *regs);
+void show_stack(const struct cpu_user_regs *regs);

... we need a newline here so it is clearer which set of functions you are referring to (at the moment one may think that dump_execution_state()) is also included.

agree

Cheers
Bertrand

Quoted 9 lines

xen/arch/arm/include/asm/processor.h extern register_t __cpu_logical_map[]; · line 566

Quoted 4 lines
xen/arch/arm/include/asm/processor.h +0 -0
 //#define dump_execution_state() run_in_exception_handler(show_execution_state)
 #define dump_execution_state() WARN()
 

Cheers,

Signature · 1 line
Julien Grall