[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/9] ACPI: address violations of MISRA C:2012 Rule 11.8



On Thu, 14 Dec 2023, Simone Ballarin wrote:
> From: Maria Celeste Cesario <maria.celeste.cesario@xxxxxxxxxxx>
> 
> The xen sources contain violations of MISRA C:2012 Rule 11.8 whose
> headline states:
> "A conversion shall not remove any const, volatile or _Atomic qualification
> from the type pointed to by a pointer".
> 
> Add missing const qualifiers missing in casting.
> There's no reason to drop the const qualifier in ACPI_COMPARE_NAME since
> the macro arguments are not modified in its body.
> 
> Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@xxxxxxxxxxx>
> Signed-off-by: Simone Ballarin  <simone.ballarin@xxxxxxxxxxx>
> ---
>  xen/include/acpi/acmacros.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/include/acpi/acmacros.h b/xen/include/acpi/acmacros.h
> index 86c503c20f..d7c74c5769 100644
> --- a/xen/include/acpi/acmacros.h
> +++ b/xen/include/acpi/acmacros.h
> @@ -116,7 +116,7 @@
>  #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
>  
>  #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
> -#define ACPI_COMPARE_NAME(a,b)          (*ACPI_CAST_PTR (u32,(a)) == 
> *ACPI_CAST_PTR (u32,(b)))
> +#define ACPI_COMPARE_NAME(a,b)          (*ACPI_CAST_PTR (const u32,(a)) == 
> *ACPI_CAST_PTR (const u32,(b)))

I am a bit confused but this one. The implementation of ACPI_CAST_PTR
is:

#define ACPI_CAST_PTR(t, p)             ((t *) (acpi_uintptr_t) (p))

The first cast to acpi_uintptr_t would already drop the const anyway?


>  #else
>  #define ACPI_COMPARE_NAME(a,b)          (!ACPI_STRNCMP (ACPI_CAST_PTR 
> (char,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE))
>  #endif

Would it make sense to also add the const here too if nothing else for
consistency?



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.