Skip to contentSkip to conversation

Fix MISRA C 2012 violations

PATCH In review Xenia Ragiadakou 2 participants 8 messages Jun 28, 2022 – Jun 29, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover Fix MISRA C 2012 violations

Resolve MISRA C 2012 Rule 8.4 warnings.

Changes in v2:
- In commit messages of patches 1-4, replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."
- Add "Reviewed-by" tags.

Xenia Ragiadakou (5):
xen/common: page_alloc: Fix MISRA C 2012 Rule 8.7 violation xen/common: vm_event: Fix MISRA C 2012 Rule 8.7 violation xen/drivers: iommu: Fix MISRA C 2012 Rule 8.7 violation xen/sched: credit: Fix MISRA C 2012 Rule 8.7 violation xen/arm64: traps: Fix MISRA C 2012 Rule 8.4 violations

 xen/arch/arm/arm64/traps.c             | 1 +
 xen/arch/arm/include/asm/arm64/traps.h | 2 ++
 xen/common/page_alloc.c                | 4 ++--
 xen/common/sched/credit.c              | 2 +-
 xen/common/vm_event.c                  | 2 +-
 xen/drivers/passthrough/iommu.c        | 2 +-
 6 files changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/5 xen/common: page_alloc: Fix MISRA C 2012 Rule 8.7 violation

The variables page_offlined_list and page_broken_list are referenced only in page_alloc.c.
Change their linkage from external to internal by adding the storage-class specifier static to their definitions.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/common/page_alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/common/page_alloc.c +2 -2
index 000ae6b972..fe0e15429a 100644
@@ -235,9 +235,9 @@ static unsigned int dma_bitsize;
 integer_param("dma_bits", dma_bitsize);
 
 /* Offlined page list, protected by heap_lock. */
-PAGE_LIST_HEAD(page_offlined_list);
+static PAGE_LIST_HEAD(page_offlined_list);
 /* Broken page list, protected by heap_lock. */
-PAGE_LIST_HEAD(page_broken_list);
+static PAGE_LIST_HEAD(page_broken_list);
 
 /*************************
  * BOOT-TIME ALLOCATOR
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/5 xen/common: vm_event: Fix MISRA C 2012 Rule 8.7 violation

In reply to Xenia Ragiadakou

The function vm_event_wake() is referenced only in vm_event.c. Change the linkage of the function from external to internal by adding the storage-class specifier static to the function definition.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/common/vm_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/vm_event.c +1 -1
index 0b99a6ea72..ecf49c38a9 100644
@@ -173,7 +173,7 @@ static void vm_event_wake_queued(struct domain *d, struct vm_event_domain *ved)
  * call vm_event_wake() again, ensuring that any blocked vCPUs will get
  * unpaused once all the queued vCPUs have made it through.
  */
-void vm_event_wake(struct domain *d, struct vm_event_domain *ved)
+static void vm_event_wake(struct domain *d, struct vm_event_domain *ved)
 {
     if ( !list_empty(&ved->wq.list) )
         vm_event_wake_queued(d, ved);
Signature · 1 line
2.34.1
Reviewed-by on v2 2/5
#3 lore raw

Re: [PATCH v2 2/5] xen/common: vm_event: Fix MISRA C 2012 Rule 8.7 violation

Quoted 9 lines · Xenia Ragiadakou

The function vm_event_wake() is referenced only in vm_event.c. Change the linkage of the function from external to internal by adding the storage-class specifier static to the function definition.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

Quoted 26 lines

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/common/vm_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/vm_event.c +1 -1
index 0b99a6ea72..ecf49c38a9 100644
@@ -173,7 +173,7 @@ static void vm_event_wake_queued(struct domain *d, struct vm_event_domain *ved)
  * call vm_event_wake() again, ensuring that any blocked vCPUs will get
  * unpaused once all the queued vCPUs have made it through.
  */
-void vm_event_wake(struct domain *d, struct vm_event_domain *ved)
+static void vm_event_wake(struct domain *d, struct vm_event_domain *ved)
 {
     if ( !list_empty(&ved->wq.list) )
         vm_event_wake_queued(d, ved);
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 3/5 xen/drivers: iommu: Fix MISRA C 2012 Rule 8.7 violation

In reply to Xenia Ragiadakou

The variable iommu_crash_disable is referenced only in one translation unit. Change its linkage from external to internal by adding the storage-class specifier static to its definition.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/drivers/passthrough/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/iommu.c +1 -1
index 75df3aa8dd..77f64e6174 100644
@@ -29,7 +29,7 @@ bool_t __initdata iommu_enable = 1;
 bool_t __read_mostly iommu_enabled;
 bool_t __read_mostly force_iommu;
 bool_t __read_mostly iommu_verbose;
-bool_t __read_mostly iommu_crash_disable;
+static bool_t __read_mostly iommu_crash_disable;
 
 #define IOMMU_quarantine_none         0 /* aka false */
 #define IOMMU_quarantine_basic        1 /* aka true */
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 4/5 xen/sched: credit: Fix MISRA C 2012 Rule 8.7 violation

In reply to Xenia Ragiadakou

The per-cpu variable last_tickle_cpu is referenced only in credit.c. Change its linkage from external to internal by adding the storage-class specifier static to its definitions.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/common/sched/credit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/sched/credit.c +1 -1
index 4d3bd8cba6..47945c2834 100644
@@ -348,7 +348,7 @@ static void burn_credits(struct csched_unit *svc, s_time_t now)
 static bool __read_mostly opt_tickle_one_idle = true;
 boolean_param("tickle_one_idle_cpu", opt_tickle_one_idle);
 
-DEFINE_PER_CPU(unsigned int, last_tickle_cpu);
+static DEFINE_PER_CPU(unsigned int, last_tickle_cpu);
 
 static inline void __runq_tickle(const struct csched_unit *new)
 {
Signature · 1 line
2.34.1
Reviewed-by on v2 4/5
#6 lore raw

Re: [PATCH v2 4/5] xen/sched: credit: Fix MISRA C 2012 Rule 8.7 violation

Quoted 9 lines · Xenia Ragiadakou

The per-cpu variable last_tickle_cpu is referenced only in credit.c. Change its linkage from external to internal by adding the storage-class specifier static to its definitions.

Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning.

Quoted 26 lines

---
Changes in v2:
- replace the phrase "This patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning." with "Also, this patch aims to resolve indirectly a MISRA C 2012 Rule 8.4 violation warning."

 xen/common/sched/credit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/sched/credit.c +1 -1
index 4d3bd8cba6..47945c2834 100644
@@ -348,7 +348,7 @@ static void burn_credits(struct csched_unit *svc, s_time_t now)
 static bool __read_mostly opt_tickle_one_idle = true;
 boolean_param("tickle_one_idle_cpu", opt_tickle_one_idle);
 
-DEFINE_PER_CPU(unsigned int, last_tickle_cpu);
+static DEFINE_PER_CPU(unsigned int, last_tickle_cpu);
 
 static inline void __runq_tickle(const struct csched_unit *new)
 {
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 5/5 xen/arm64: traps: Fix MISRA C 2012 Rule 8.4 violations

In reply to Xenia Ragiadakou

Add a function prototype for do_bad_mode() in <asm/arm64/traps.h> and include header <asm/traps.h> in traps.c, so that the declarations of the functions do_bad_mode() and finalize_instr_emulation(), which have external linkage, are visible before the function definitions.

---
Changes in v2:
- none

 xen/arch/arm/arm64/traps.c             | 1 +
 xen/arch/arm/include/asm/arm64/traps.h | 2 ++
 2 files changed, 3 insertions(+)
xen/arch/arm/arm64/traps.c +1 -0
index 3f8858acec..a995ad7c2c 100644
@@ -22,6 +22,7 @@
 #include <asm/hsr.h>
 #include <asm/system.h>
 #include <asm/processor.h>
+#include <asm/traps.h>
 
 #include <public/xen.h>
 
xen/arch/arm/include/asm/arm64/traps.h +2 -0
index 2379b578cb..a347cb13d6 100644
@@ -6,6 +6,8 @@ void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len);
 void do_sysreg(struct cpu_user_regs *regs,
                const union hsr hsr);
 
+void do_bad_mode(struct cpu_user_regs *regs, int reason);
+
 #endif /* __ASM_ARM64_TRAPS__ */
 /*
  * Local variables:
Signature · 1 line
2.34.1