address remaining violations of MISRA C:2012 Rule 11.9
PATCH 2/5 x86/ioapic: use NULL as a null pointer constant
In reply to Nicola VetriniResolves violations of MISRA C Rule 11.9.
No functional change.
--- xen/arch/x86/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/io_apic.c +2 -2
@@ -207,7 +207,7 @@ struct IO_APIC_route_entry **alloc_ioapic_entries(void) ioapic_entries = xmalloc_array(struct IO_APIC_route_entry *, nr_ioapics);if (!ioapic_entries) -return 0 ; +return NULL ;for (apic =0 ; apic < nr_ioapics; apic++) { ioapic_entries[apic] =
@@ -224,7 +224,7 @@ nomem:xfree (ioapic_entries[apic]);xfree (ioapic_entries); -return 0 ; +return NULL ; }union entry_union {
Signature · 1 line
2.34.1
PATCH 3/5 xen/acpi: Use NULL as a null pointer constant
In reply to Nicola VetriniResolves a violation of MISRA C Rule 11.9.
No functional change.
--- xen/include/acpi/acmacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/acpi/acmacros.h +1 -1
@@ -111,7 +111,7 @@#define ACPI_TO_POINTER (i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i)#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p,(void *) NULL) -#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) +#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)NULL)->f),(void *) NULL)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
Signature · 1 line
2.34.1
PATCH 4/5 x86/hvm: dom0: use helper to get sizeof struct field
In reply to Nicola VetriniUse of the proper helper macro also resolves a violation of MISRA C Rule 11.9.
No functional change.
--- xen/arch/x86/hvm/dom0_build.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
xen/arch/x86/hvm/dom0_build.c +1 -2
@@ -1144,8 +1144,7 @@ static int __init pvh_setup_acpi(struct domain *d, paddr_t start_info) rc =hvm_copy_to_guest_phys (start_info + offsetof(struct hvm_start_info , rsdp_paddr), &rsdp_paddr, -sizeof (((struct hvm_start_info *) -0 )->rsdp_paddr), + sizeof_field(struct hvm_start_info, rsdp_paddr), d->vcpu[0 ]);if ( rc ) {
Signature · 1 line
2.34.1
PATCH 5/5 xen/wait: address violations of MISRA C Rule 11.9
In reply to Nicola VetriniNo functional change.
--- xen/common/wait.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/common/wait.c +2 -2
@@ -125,7 +125,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv)struct vcpu *curr = current;unsigned long dummy; -ASSERT (wqv->esp ==0 ); +ASSERT (wqv->esp ==NULL );/* Save current VCPU affinity; force wakeup on *this* CPU only. */ if (vcpu_temporary_affinity (curr,smp_processor_id (),VCPU_AFFINITY_WAIT ) )
@@ -171,7 +171,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) [sz] "i" (PAGE_SIZE) : "memory", "rax", "rdx", "r8", "r9", "r10", "r11" ); -if (unlikely (wqv->esp ==0 ) ) +if (unlikely (wqv->esp ==NULL ) ) {gdprintk (XENLOG_ERR ,"Stack too large in %s\n" , __func__);domain_crash (curr->domain);
Signature · 1 line
2.34.1
cover address remaining violations of MISRA C:2012 Rule 11.9
Hi all,
this series resolves violations of MISRA C:2012 Rule 11.9. After this series is applied the rule has no violations on both ARM and x86.
Nicola Vetrini (5):
xen/hvm: use NULL as a null pointer constant x86/ioapic: use NULL as a null pointer constant xen/acpi: Use NULL as a null pointer constant x86/hvm: dom0: use helper to get sizeof struct field xen/wait: address violations of MISRA C Rule 11.9
xen/arch/x86/hvm/dom0_build.c | 3 +-- xen/arch/x86/include/asm/hvm/irq.h | 2 +- xen/arch/x86/io_apic.c | 4 ++-- xen/common/wait.c | 4 ++-- xen/include/acpi/acmacros.h | 2 +- xen/include/public/hvm/save.h | 8 ++++---- 6 files changed, 11 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/5 xen/hvm: use NULL as a null pointer constant
No functional change.
--- xen/arch/x86/include/asm/hvm/irq.h | 2 +- xen/include/public/hvm/save.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/include/asm/hvm/irq.h +1 -1
@@ -136,7 +136,7 @@ struct hvm_girq_dpci_mapping {#define NR_ISAIRQS 16#define NR_LINK 4 -#define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl) +#define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)NULL)->redirtbl)/* Protected by domain's event_lock */ struct hvm_irq_dpci {
xen/include/public/hvm/save.h +4 -4
@@ -65,15 +65,15 @@ struct hvm_save_descriptor { struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char cpt[1];}#endif -#define HVM_SAVE_TYPE (_x) __typeof__ (((struct __HVM_SAVE_TYPE_##_x *)(0))->t) +#define HVM_SAVE_TYPE (_x) __typeof__ (((struct __HVM_SAVE_TYPE_##_x *)(NULL))->t)#define HVM_SAVE_LENGTH (_x) (sizeof (HVM_SAVE_TYPE(_x))) -#define HVM_SAVE_CODE (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c)) +#define HVM_SAVE_CODE (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(NULL))->c))#ifdef __XEN__ -# define HVM_SAVE_TYPE_COMPAT (_x) __typeof__ (((struct __HVM_SAVE_TYPE_COMPAT_##_x *)(0))->t) +# define HVM_SAVE_TYPE_COMPAT (_x) __typeof__ (((struct __HVM_SAVE_TYPE_COMPAT_##_x *)(NULL))->t)# define HVM_SAVE_LENGTH_COMPAT (_x) (sizeof (HVM_SAVE_TYPE_COMPAT(_x))) -# define HVM_SAVE_HAS_COMPAT (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->cpt)-1) +# define HVM_SAVE_HAS_COMPAT (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(NULL))->cpt)-1)# define HVM_SAVE_FIX_COMPAT (_x, _dst, _size) __HVM_SAVE_FIX_COMPAT_##_x(_dst, _size)#endif
Signature · 1 line
2.34.1
Re: [XEN PATCH 1/5] xen/hvm: use NULL as a null pointer constant
Quoted 3 lines · Nicola Vetrini
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Re: [XEN PATCH 2/5] x86/ioapic: use NULL as a null pointer constant
In reply to Nicola VetriniQuoted 4 lines · Nicola Vetrini
Resolves violations of MISRA C Rule 11.9.
No functional change.Signed-off-by Nicola Vetrini <[email protected]>
Re: [XEN PATCH 3/5] xen/acpi: Use NULL as a null pointer constant
In reply to Nicola VetriniQuoted 4 lines · Nicola Vetrini
Resolves a violation of MISRA C Rule 11.9.
No functional change.Signed-off-by Nicola Vetrini <[email protected]>
Re: [XEN PATCH 4/5] x86/hvm: dom0: use helper to get sizeof struct field
In reply to Nicola VetriniQuoted 5 lines · Nicola Vetrini
Use of the proper helper macro also resolves a violation of MISRA C Rule 11.9.
No functional change.Signed-off-by Nicola Vetrini <[email protected]>
Re: [XEN PATCH 5/5] xen/wait: address violations of MISRA C Rule 11.9
In reply to Nicola VetriniQuoted 3 lines · Nicola Vetrini
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Jan Beulich
Acked-byRe: [XEN PATCH 1/5] xen/hvm: use NULL as a null pointer constant
In reply to Stefano StabelliniQuoted 6 lines · Stefano Stabellini
Quoted 3 lines · Nicola Vetrini
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Yet it would have been really nice if style had been tidied of the lines which are touched anyway.
Jan
Jan Beulich
Acked-byRe: [XEN PATCH 2/5] x86/ioapic: use NULL as a null pointer constant
In reply to Stefano StabelliniQuoted 7 lines · Stefano Stabellini
Quoted 4 lines · Nicola Vetrini
Resolves violations of MISRA C Rule 11.9.
No functional change.Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Re: [XEN PATCH 3/5] xen/acpi: Use NULL as a null pointer constant
In reply to Nicola Vetrinixen/include/acpi/acmacros.h line 117
Quoted 11 lines · Nicola Vetrini
xen/include/acpi/acmacros.h +1
-1@@ -111,7 +111,7 @@#define ACPI_TO_POINTER (i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i)#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p,(void *) NULL) -#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) +#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)NULL)->f),(void *) NULL)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
This again is an ACPI CA header, which I'm hesitant to see being changed.
Jan
Re: [XEN PATCH 3/5] xen/acpi: Use NULL as a null pointer constant
Quoted 19 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini
xen/include/acpi/acmacros.h +1
-1@@ -111,7 +111,7 @@#define ACPI_TO_POINTER (i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i)#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p,(void *) NULL) -#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) +#define ACPI_OFFSET (d,f) (acpi_size) ACPI_PTR_DIFFQuoted 4 lines
(&(((d *)NULL)->f),(void *) NULL)
#defineACPI_PHYSADDR_TO_PTR(i)ACPI_TO_POINTER(i)
#defineACPI_PTR_TO_PHYSADDR(i)ACPI_TO_INTEGER(i)This again is an ACPI CA header, which I'm hesitant to see being changed.
Quoted 1 line
Jan
Yes, I sent this before the discussion on R11.8. I'm ok with adding all these files derived from ACPI CA to exclude-list.json, so in that case the patch can be ignored.
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Jan Beulich
Acked-byRe: [XEN PATCH 4/5] x86/hvm: dom0: use helper to get sizeof struct field
In reply to Stefano StabelliniQuoted 8 lines · Stefano Stabellini
Quoted 5 lines · Nicola Vetrini
Use of the proper helper macro also resolves a violation of MISRA C Rule 11.9.
No functional change.Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Re: [XEN PATCH 5/5] xen/wait: address violations of MISRA C Rule 11.9
In reply to Nicola VetriniQuoted 3 lines · Nicola Vetrini
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Nevertheless, imo ...
Quoted 12 lines
xen/common/wait.c +1
-1@@ -125,7 +125,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv)struct vcpu *curr = current;unsigned long dummy; -ASSERT (wqv->esp ==0 ); +ASSERT (wqv->esp ==NULL );/* Save current VCPU affinity; force wakeup on *this* CPU only. */ if (vcpu_temporary_affinity (curr,smp_processor_id (),VCPU_AFFINITY_WAIT ) )
xen/common/wait.c static void __prepare_to_wait(struct waitqueue_vcpu *wqv) · line 177
Quoted 8 lines
xen/common/wait.c +1
-1@@ -171,7 +171,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) [sz] "i" (PAGE_SIZE) : "memory", "rax", "rdx", "r8", "r9", "r10", "r11" ); -if (unlikely (wqv->esp ==0 ) ) +if (unlikely (wqv->esp ==NULL ) ) {gdprintk (XENLOG_ERR ,"Stack too large in %s\n" , __func__);domain_crash (curr->domain);
... in both cases the better change (more in line with what we do elsewhere, even if not liked by Misra and hence being deviated by us) would have been to use ! in place of == NULL.
Jan