[XEN PATCH] xen/iommu_init: address a violation of MISRA C:2012 Rule 8.3

Federico Serafini posted 1 patch 6 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/cfd803a27efaa529b4e972acc1fa6a8f0e20c9c0.1698155675.git.federico.serafini@bugseng.com
xen/drivers/passthrough/amd/iommu_init.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[XEN PATCH] xen/iommu_init: address a violation of MISRA C:2012 Rule 8.3
Posted by Federico Serafini 6 months, 1 week ago
Change parameter name and emphasize that it is deliberately not used through a
comment followed by the statement '(void) data;'.
This also addresses a violation of MISRA C:2012 Rule 2.7 ("A function should
not contain unused parameters").

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
 xen/drivers/passthrough/amd/iommu_init.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 9c01a49435..5bfaa6cdd4 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -692,7 +692,7 @@ static void iommu_check_ppr_log(struct amd_iommu *iommu)
     spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
-static void cf_check do_amd_iommu_irq(void *unused)
+static void cf_check do_amd_iommu_irq(void *data)
 {
     struct amd_iommu *iommu;
 
@@ -702,6 +702,11 @@ static void cf_check do_amd_iommu_irq(void *unused)
         return;
     }
 
+    /*
+     * Formal parameter is deliberately unused.
+     */
+    (void) data;
+
     /*
      * No matter from where the interrupt came from, check all the
      * IOMMUs present in the system. This allows for having just one
-- 
2.34.1
Re: [XEN PATCH] xen/iommu_init: address a violation of MISRA C:2012 Rule 8.3
Posted by Jan Beulich 6 months, 1 week ago
On 24.10.2023 16:01, Federico Serafini wrote:
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -692,7 +692,7 @@ static void iommu_check_ppr_log(struct amd_iommu *iommu)
>      spin_unlock_irqrestore(&iommu->lock, flags);
>  }
>  
> -static void cf_check do_amd_iommu_irq(void *unused)
> +static void cf_check do_amd_iommu_irq(void *data)
>  {
>      struct amd_iommu *iommu;
>  
> @@ -702,6 +702,11 @@ static void cf_check do_amd_iommu_irq(void *unused)
>          return;
>      }
>  
> +    /*
> +     * Formal parameter is deliberately unused.
> +     */
> +    (void) data;

Besides me thinking that the original way of expressing things was more
clear (and still even machine-recognizable), there are (nit) also style
issues here: The comment is malformed and there shouldn't be a blank
between the cast operator and the expression it applies to.

Jan