diff mbox series

[3/5] AMD/IOMMU: address violations of MISRA C:2012 Rule 11.8

Message ID 11fc193f35be188165294665b1e989b2db17a776.1700842832.git.maria.celeste.cesario@bugseng.com (mailing list archive)
State Superseded
Headers show
Series xen: address violations of MISRA C:2012 Rule 11.8 | expand

Commit Message

Simone Ballarin Nov. 24, 2023, 4:29 p.m. UTC
From: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>

Add missing const qualifier in casting to comply with Rule 11.8.
The type of the formal parameter ivhd_block is const qualified.
No functional change.

Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@bugseng.com>
Signed-off-by: Simone Ballarin  <simone.ballarin@bugseng.com>
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Cooper Nov. 24, 2023, 5:53 p.m. UTC | #1
On 24/11/2023 4:29 pm, Simone Ballarin wrote:
> From: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
>
> Add missing const qualifier in casting to comply with Rule 11.8.
> The type of the formal parameter ivhd_block is const qualified.
> No functional change.
>
> Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@bugseng.com>
> Signed-off-by: Simone Ballarin  <simone.ballarin@bugseng.com>
> ---
>  xen/drivers/passthrough/amd/iommu_acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
> index 699d33f429..00923a6bb5 100644
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -1232,7 +1232,7 @@ static int __init get_last_bdf_ivhd(
>      while ( ivhd_block->header.length >=
>              (block_length + sizeof(struct acpi_ivrs_de_header)) )
>      {
> -        ivhd_device = (const void *)((u8 *)ivhd_block + block_length);
> +        ivhd_device = (const void *)((const uint8_t *)ivhd_block + block_length);

This we should simplify into just:

    ivhd_device = (const void *)ivhd_block + block_length;

We use this GCC extension in many other places too.

~Andrew
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 699d33f429..00923a6bb5 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -1232,7 +1232,7 @@  static int __init get_last_bdf_ivhd(
     while ( ivhd_block->header.length >=
             (block_length + sizeof(struct acpi_ivrs_de_header)) )
     {
-        ivhd_device = (const void *)((u8 *)ivhd_block + block_length);
+        ivhd_device = (const void *)((const uint8_t *)ivhd_block + block_length);
 
         switch ( ivhd_device->header.type )
         {