xen/arm: traps: fix MISRA C 2012 Rule 8.7 violation
PATCH 1/1 xen/arm: traps: fix MISRA C 2012 Rule 8.7 violation
The functions show_registers() and show_stack() are referenced only in traps.c. Change their linkage from external to internal by adding the storage-class specifier static to their definitions and by removing show_registers() from asm/processor.h header file.
Also, this patch resolves a MISRA C 2012 Rule 8.4 violation warning about the function show_stack().
---
I am not 100% sure about this patch.
I think show_stack() should be declared the same way as show_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.
I decided to declare both of them static because they are referenced only in traps.c but I could have, also, add the declaration of show_stack() in asm/processor.h header instead. Rule 8.7 is advisory.
xen/arch/arm/include/asm/processor.h | 1 - xen/arch/arm/traps.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
xen/arch/arm/include/asm/processor.h +0 -1
@@ -558,7 +558,6 @@ extern register_t __cpu_logical_map[];void panic_PAR (uint64_t par);void show_execution_state (const struct cpu_user_regs *regs); -void show_registers (const struct cpu_user_regs *regs);//#define dump_execution_state() run_in_exception_handler(show_execution_state) #define dump_execution_state () WARN()
xen/arch/arm/traps.c +2 -2
@@ -931,7 +931,7 @@ static void _show_registers(const struct cpu_user_regs *regs,printk ("\n" ); } -void show_registers (const struct cpu_user_regs *regs) +static void show_registers (const struct cpu_user_regs *regs) {struct reg_ctxt ctxt; ctxt.sctlr_el1 =READ_SYSREG (SCTLR_EL1 );
@@ -1146,7 +1146,7 @@ static void show_trace(const struct cpu_user_regs *regs)printk ("\n" ); } -void show_stack (const struct cpu_user_regs *regs) +static void show_stack (const struct cpu_user_regs *regs) {register_t *stack =STACK_BEFORE_EXCEPTION (regs), addr;int i;
Signature · 1 line
2.34.1
Hi Xenia,
Quoted 10 lines · Xenia Ragiadakou
The functions
show_registers()andshow_stack()are referenced only intraps.c. Change their linkage from external to internal by adding the storage-class specifier static to their definitions and by removingshow_registers()fromasm/processor.hheader file.Also, this patch resolves a MISRA C 2012 Rule 8.4 violation warning about the function
show_stack().
Quoted 6 lines
Signed-off-by Xenia Ragiadakou <[email protected]>---
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.
I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.
Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.
As said I would vote for external linkage here but would be nice to have other developers view on this.
Cheers
Bertrand
Quoted 42 lines
xen/arch/arm/include/asm/processor.h| 1 -xen/arch/arm/traps.c| 4 ++--2 files changed, 2 insertions(+), 3 deletions(-)xen/arch/arm/include/asm/processor.h +0
-1@@ -558,7 +558,6 @@ extern register_t __cpu_logical_map[];void panic_PAR (uint64_t par);void show_execution_state (const struct cpu_user_regs *regs); -void show_registers (const struct cpu_user_regs *regs);//#define dump_execution_state() run_in_exception_handler(show_execution_state) #define dump_execution_state () WARN()xen/arch/arm/traps.c +2
-2@@ -931,7 +931,7 @@ static void _show_registers(const struct cpu_user_regs *regs,printk ("\n" ); } -void show_registers (const struct cpu_user_regs *regs) +static void show_registers (const struct cpu_user_regs *regs) {struct reg_ctxt ctxt; ctxt.sctlr_el1 =READ_SYSREG (SCTLR_EL1 );@@ -1146,7 +1146,7 @@ static void show_trace(const struct cpu_user_regs *regs)printk ("\n" ); } -void show_stack (const struct cpu_user_regs *regs) +static void show_stack (const struct cpu_user_regs *regs) {register_t *stack =STACK_BEFORE_EXCEPTION (regs), addr;int i;Signature · 1 line
2.34.1
Quoted 11 lines
Quoted 5 lines
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.
Quoted 7 lines
Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Quoted 2 lines
Cheers
Bertrand
Quoted 15 lines · Luca Fancellu
Quoted 15 lines
Quoted 5 lines
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.
Quoted 6 lines
Quoted 3 lines
As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Quoted 4 lines
Quoted 3 lines
Cheers
Bertrand
Signature · 1 line
Xenia
Quoted 21 lines · Xenia Ragiadakou
Quoted 14 lines · Luca Fancellu
Quoted 14 lines
Quoted 4 lines
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Yes that is true, in that case we would only need to document it without a formal justification, however if the codebase doesn’t include them (because not in production code) I guess the problem doesn’t exist.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Cheers
BertrandSignature · 1 line
Xenia
Quoted 28 lines · Luca Fancellu
Quoted 25 lines · Xenia Ragiadakou
Quoted 17 lines · Luca Fancellu
Quoted 17 lines
Quoted 4 lines
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.As said I would vote for external linkage here but would be nice to have other developers view on this.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Yes that is true, in that case we would only need to document it without a formal justification, however if the codebase doesn’t include them (because not in production code) I guess the problem doesn’t exist.
Having the production code using static and the non production using external linkage would be kind of weird here. I think having them always with external linkage with a justification is the cleanest way.
Cheers
Bertrand
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Cheers
Bertrand--
Xenia
Hi,
Quoted 29 lines · Bertrand Marquis
Quoted 29 lines · Luca Fancellu
Quoted 28 lines · Xenia Ragiadakou
Quoted 19 lines · Luca Fancellu
Quoted 10 lines
Quoted 4 lines
I am not 100% sure about this patch.
I thinkshow_stack()should be declared the same way asshow_registers(). So either both of them will be declared with external linkage or both of them will be declared with internal linkage.I think that those 2 should be declared with external linkage with a comment explaining why they are. For me those are useful when developing or debugging and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.Quoted 7 lines
Quoted 3 lines
I decided to declare both of them static because they are referenced only in
traps.cbut I could have, also, add the declaration ofshow_stack()inasm/processor.hheader instead. Rule 8.7 is advisory.As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Yes that is true, in that case we would only need to document it without a formal justification, however if the codebase doesn’t include them (because not in production code) I guess the problem doesn’t exist.
Having the production code using static and the non production using external linkage would be kind of weird here. I think having them always with external linkage with a justification is the cleanest way.
+1 this is what I was going to answer :).
Cheers,
Signature · 1 line
Julien Grall
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Yes that is true, in that case we would only need to document it without a formal justification, however if the codebase doesn’t include them (because not in production code) I guess the problem doesn’t exist.
Having the production code using static and the non production using external linkage would be kind of weird here. I think having them always with external linkage with a justification is the cleanest way.
+1 this is what I was going to answer :).
Yes probably I didn’t explained very well, I’m in favour for external linkage, hence we are going to have an advisory to document.
I was just thinking if we need to document that *if* the codebase doesn’t include them, which is a comment not related to this patch so apologies for the noise on that.
Quoted 4 lines
Cheers,
Signature · 1 line
Julien Grall
Quoted 14 lines · Luca Fancellu
Quoted 14 lines
Quoted 13 lines
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
As said I would vote for external linkage here but would be nice to have other developers view on this.
In addition to this, if we don’t want to provide a justification for those, since they seems to me code related to debugging they can be removed from “production” code in some way.
Rule 8.7 is advisory, so I think that formal justification of deviations is not necessary.
Yes that is true, in that case we would only need to document it without a formal justification, however if the codebase doesn’t include them (because not in production code) I guess the problem doesn’t exist.
Having the production code using static and the non production using external linkage would be kind of weird here. I think having them always with external linkage with a justification is the cleanest way.
Quoted 14 lines
Quoted 2 lines
+1 this is what I was going to answer :).
Yes probably I didn’t explained very well, I’m in favour for external linkage, hence we are going to have an advisory to document.
I was just thinking if we need to document that *if* the codebase doesn’t include them, which is a comment not related to this patch so apologies for the noise on that.
Quoted 4 lines
Cheers,
Signature · 1 line
Julien Grall
I would like to mention that show_execution_state() is also available for dumping the state but probably you need them for more fine grained debugging. I will wait until tomorrow in case there is further input on this and I will send another patch, if necessary.
Signature · 1 line
Xenia