Misc MISRA fixes for default Xen build configurations
cover Misc MISRA fixes for default Xen build configurations
This series addresses some of the violations found by widening the scope of application of MISRA checking to default builds of Xen for both ARM64 and x86_64.
While it has been tested on top of a patch yet to be applied (but with the necessary R-by [1]) these fixes can go in independently of that.
As evidenced by the CI pipeline below, there are a number of regressions on guidelines that were clean on the restricted scope but are not in the wider one; the patches in this series address a subset of those.
CI pipeline: https://gitlab.com/xen-project/people/bugseng/xen/-/pipelines/2156782159
Nicola Vetrini (4):
xen/xsm: address violations of MISRA C rules 8.3 and 7.2 xen/sched: address violation of MISRA C Rule 16.3 xen/param: address violation of MISRA C Rule 20.7 xen/param: address violation of MISRA C Rule 8.2
xen/common/sched/credit.c | 2 +- xen/include/xen/param.h | 6 +++--- xen/include/xsm/xsm.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.51.2
PATCH 3/4 xen/param: address violation of MISRA C Rule 20.7
The rule states: Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses.
Add parentheses in the defition of `custom_runtime_var_sz' to address the violations.
No functional change.
--- xen/include/xen/param.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/xen/param.h +2 -2
@@ -102,8 +102,8 @@ extern struct param_hypfs __paramhypfs_start[], __paramhypfs_end[];#define custom_runtime_set_var_sz (parfs, var, sz) \ { \ - (parfs)->hypfs.u.content = var; \ - (parfs)->hypfs.e.max_size = sz; \ + (parfs)->hypfs.u.content = (var); \ + (parfs)->hypfs.e.max_size = (sz); \ (parfs)->hypfs.e.size = strlen(var) + 1; \ }#define custom_runtime_set_var (parfs, var) \
Signature · 1 line
2.51.2
PATCH 4/4 xen/param: address violation of MISRA C Rule 8.2
In reply to Nicola Vetriniadd missing parameter name in function pointer member declaration.
No functional change.
--- xen/include/xen/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/xen/param.h +1 -1
@@ -90,7 +90,7 @@ extern const struct kernel_param __setup_start[], __setup_end[];struct param_hypfs {struct hypfs_entry_leaf hypfs;void (*init_leaf)(struct param_hypfs *par); -int (*func)(const char *); +int (*func)(const char *s); };extern struct param_hypfs __paramhypfs_start[], __paramhypfs_end[];
Signature · 1 line
2.51.2
PATCH 1/4 xen/xsm: address violations of MISRA C rules 8.3 and 7.2
In reply to Nicola VetriniRule 8.3 states: Function types shall be in prototype form with named parameters.
add parameter to 'has_xsm_magic' to make it consistent with the definition.
Rule 7.2 states: A u' or U' suffix shall be applied to all integer constants that are represented in an unsigned type.
add missing U' to both #define for XSM_MAGIC` for consistency.
No functional change.
--- xen/include/xsm/xsm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/xsm/xsm.h +3 -3
@@ -22,9 +22,9 @@typedef uint32_t xsm_magic_t ;#ifdef CONFIG_XSM_FLASK -#define XSM_MAGIC 0xf97cff8c +#define XSM_MAGIC 0xf97cff8cU#else -#define XSM_MAGIC 0x0 +#define XSM_MAGIC 0x0U#endif /*
@@ -815,7 +815,7 @@ int xsm_multiboot_policy_init(*/ int xsm_dt_init (void );int xsm_dt_policy_init (void **policy_buffer,size_t *policy_size); -bool has_xsm_magic (paddr_t ); +bool has_xsm_magic (paddr_t start);#endif void xsm_fixup_ops (struct xsm_ops *ops);
Signature · 1 line
2.51.2
PATCH 2/4 xen/sched: address violation of MISRA C Rule 16.3
In reply to Nicola VetriniThe rule states: An unconditional `break' statement shall terminate every switch-clause.
Use the `fallthrough' pseudo-keyword for which an ECLAIR deviation is already in place.
No functional change.
--- xen/common/sched/credit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/sched/credit.c +1 -1
@@ -1288,7 +1288,7 @@ csched_sys_cntl(const struct scheduler *ops, prv->unit_migr_delay =MICROSECS (params->vcpu_migr_delay_us);spin_unlock_irqrestore (&prv->lock, flags); -/* FALLTHRU */ + fallthrough;case XEN_SYSCTL_SCHEDOP_getinfo: params->tslice_ms = prv->tslice /MILLISECS (1 ); params->ratelimit_us = prv->ratelimit /MICROSECS (1 );
Signature · 1 line
2.51.2
Re: [PATCH 2/4] xen/sched: address violation of MISRA C Rule 16.3
Quoted 9 lines · Nicola Vetrini
The rule states: An unconditional `break' statement shall terminate every switch-clause.
Use the `fallthrough' pseudo-keyword for which an ECLAIR deviation is already in place.
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Juergen
Re: [PATCH 3/4] xen/param: address violation of MISRA C Rule 20.7
In reply to Nicola VetriniQuoted 9 lines · Nicola Vetrini
The rule states: Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses.
Add parentheses in the defition of `custom_runtime_var_sz' to address the violations.
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Re: [PATCH 4/4] xen/param: address violation of MISRA C Rule 8.2
In reply to Nicola VetriniQuoted 5 lines · Nicola Vetrini
add missing parameter name in function pointer member declaration.
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Re: [PATCH 1/4] xen/xsm: address violations of MISRA C rules 8.3 and 7.2
In reply to Nicola VetriniQuoted 35 lines · Nicola Vetrini
Rule 8.3 states: Function types shall be in prototype form with named parameters.
add parameter to '
has_xsm_magic' to make it consistent with the definition.Rule 7.2 states: A
u' orU' suffix shall be applied to all integer constants that are represented in an unsigned type.add missing
U' to both #define forXSM_MAGIC` for consistency.No functional change.
Signed-off-by Nicola Vetrini <[email protected]>--- xen/include/xsm/xsm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/include/xsm/xsm.h +2
-2@@ -22,9 +22,9 @@typedef uint32_t xsm_magic_t ;#ifdef CONFIG_XSM_FLASK -#define XSM_MAGIC 0xf97cff8c +#define XSM_MAGIC 0xf97cff8cU#else -#define XSM_MAGIC 0x0 +#define XSM_MAGIC 0x0U#endif /*
xen/include/xsm/xsm.h int xsm_multiboot_policy_init( · line 821
Quoted 8 lines
xen/include/xsm/xsm.h +1
-1@@ -815,7 +815,7 @@ int xsm_multiboot_policy_init(*/ int xsm_dt_init (void );int xsm_dt_policy_init (void **policy_buffer,size_t *policy_size); -bool has_xsm_magic (paddr_t ); +bool has_xsm_magic (paddr_t start);#endif void xsm_fixup_ops (struct xsm_ops *ops);