Fix MISRA regressions for new ARM64 configurations
cover Fix MISRA regressions for new ARM64 configurations
After addition of new eclair scans for other configurations like defconfig, some regressions for clean rules were reported. This series focuses on report generated for ARM64 and gets rid of all the regressions.
Diff:
eclair-ARM64{-testing}: was 22 regressions, now 0 eclair-x86_64{-testing}: was 359 regressions, now 337
https://gitlab.com/xen-project/people/morzel/xen/-/pipelines/2197932219
Michal Orzel (3):
public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK common/kernel: Rename hypfs "params" variable xen/hypfs: Enclose HYPFS_DIR_INIT var parameter in parentheses
xen/common/kernel.c | 6 +++--- xen/include/public/trace.h | 2 +- xen/include/xen/hypfs.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK
TRC_PV_HYPERCALL_V2_ARG_MASK represents unsigned type, so according to MISRA C R7.2. U suffix should be applied. Fix the violation.
--- xen/include/public/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/trace.h +1 -1
@@ -157,7 +157,7 @@*/ #define TRC_PV_HYPERCALL_V2_ARG_32 (i) (0x1 << (20 + 2*(i)))#define TRC_PV_HYPERCALL_V2_ARG_64 (i) (0x2 << (20 + 2*(i))) -#define TRC_PV_HYPERCALL_V2_ARG_MASK (0xfff00000) +#define TRC_PV_HYPERCALL_V2_ARG_MASK (0xfff00000U)#define TRC_SHADOW_NOT_SHADOW (TRC_SHADOW + 1)#define TRC_SHADOW_FAST_PROPAGATE (TRC_SHADOW + 2)
Signature · 1 line
2.43.0
Re: [PATCH 1/3] public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK
Quoted 13 lines · Michal Orzel
TRC_PV_HYPERCALL_V2_ARG_MASKrepresents unsigned type, so according to MISRA C R7.2. U suffix should be applied. Fix the violation.Signed-off-by Michal Orzel <[email protected]>--- xen/include/public/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/include/public/trace.h +0
-0
xen/include/public/trace.h line 163
Quoted 8 lines
xen/include/public/trace.h +1
-1@@ -157,7 +157,7 @@*/ #define TRC_PV_HYPERCALL_V2_ARG_32 (i) (0x1 << (20 + 2*(i)))#define TRC_PV_HYPERCALL_V2_ARG_64 (i) (0x2 << (20 + 2*(i))) -#define TRC_PV_HYPERCALL_V2_ARG_MASK (0xfff00000) +#define TRC_PV_HYPERCALL_V2_ARG_MASK (0xfff00000U)#define TRC_SHADOW_NOT_SHADOW (TRC_SHADOW + 1)#define TRC_SHADOW_FAST_PROPAGATE (TRC_SHADOW + 2)
Hmm. Ideally we should use _AC() (or whatever monstrosity we call it in the public headers), but this header contains C structs unguarded by __ASSEMBL{ER,Y}__ so we don't need to be so careful.
changing it, you can drop the brackets too.
PATCH 2/3 common/kernel: Rename hypfs "params" variable
In reply to Michal OrzelInside do_xen_version, there are two other places using local variables named "params". Rename hypfs dir "params" to "params_dir". This resolves MISRA C R5.3 violation.
--- xen/common/kernel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/common/kernel.c +3 -3
@@ -483,13 +483,13 @@ static int __init cf_check buildinfo_init(void) }__initcall (buildinfo_init); -static HYPFS_DIR_INIT(params, "params"); +static HYPFS_DIR_INIT(params_dir, "params"); static int __init cf_check param_init(void) {struct param_hypfs *param; -hypfs_add_dir (&hypfs_root, ¶ms, true); +hypfs_add_dir (&hypfs_root, ¶ms_dir, true);for ( param = __paramhypfs_start; param < __paramhypfs_end; param++ ) {
@@ -497,7 +497,7 @@ static int __init cf_check param_init(void) param->init_leaf (param); else if ( param->hypfs.e.type == XEN_HYPFS_TYPE_STRING ) param->hypfs.e.size = strlen(param->hypfs.u.content) + 1; -hypfs_add_leaf (¶ms, ¶m->hypfs, true); +hypfs_add_leaf (¶ms_dir, ¶m->hypfs, true); }return 0 ;
Signature · 1 line
2.43.0
Re: [PATCH 2/3] common/kernel: Rename hypfs "params" variable
Quoted 5 lines · Michal Orzel
Inside
do_xen_version, there are two other places using local variables named "params". Rename hypfs dir "params" to "params_dir". This resolves MISRA C R5.3 violation.Signed-off-by Michal Orzel <[email protected]>
Equally, the two things called params could be shorted to p, but "params" is a common general name so this approach is probably better.
PATCH 3/3 xen/hypfs: Enclose HYPFS_DIR_INIT var parameter in parentheses
In reply to Michal OrzelThe var parameter is later on expanded and referenced by LIST_HEAD_INIT and shall be enclosed in parentheses. This resolves MISRA C R20.7 violation.
--- xen/include/xen/hypfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/xen/hypfs.h +2 -2
@@ -95,9 +95,9 @@ struct hypfs_dyndir_id { .e.name = (nam), \ .e.size = 0, \ .e.max_size = 0, \ - .e.list = LIST_HEAD_INIT(var.e.list), \ + .e.list = LIST_HEAD_INIT((var).e.list), \ .e.funcs = (fn), \ - .dirlist = LIST_HEAD_INIT(var.dirlist), \ + .dirlist = LIST_HEAD_INIT((var).dirlist), \ }#define HYPFS_DIR_INIT (var, nam) \
Signature · 1 line
2.43.0
Re: [PATCH 3/3] xen/hypfs: Enclose HYPFS_DIR_INIT var parameter in parentheses
Quoted 5 lines · Michal Orzel
The var parameter is later on expanded and referenced by
LIST_HEAD_INITand shall be enclosed in parentheses. This resolves MISRA C R20.7 violation.Signed-off-by Michal Orzel <[email protected]>
Juergen