All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH 0/2] xen: address MISRA C:2012 Rule 5.3
@ 2023-08-09  7:55 Nicola Vetrini
  2023-08-09  7:55 ` [XEN PATCH 1/2] x86/vmsi: rename variables to " Nicola Vetrini
  2023-08-09  7:55 ` [XEN PATCH 2/2] xen/delay: " Nicola Vetrini
  0 siblings, 2 replies; 8+ messages in thread
From: Nicola Vetrini @ 2023-08-09  7:55 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Nicola Vetrini, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Wei Liu, George Dunlap, Julien Grall

This series contains two patches left from previous series addressing the same
MISRA Rule [1] [2], to make a standalone patch with the more involved changes
that the first patch of [1] brings. The review comments on the respective threads
about these patches have been addressed.

[1] https://lore.kernel.org/xen-devel/cover.1691492441.git.nicola.vetrini@bugseng.com/
[2] https://lore.kernel.org/xen-devel/cover.1691488505.git.nicola.vetrini@bugseng.com/

Nicola Vetrini (2):
  x86/vmsi: rename variables to address MISRA C:2012 Rule 5.3
  xen/delay: address MISRA C:2012 Rule 5.3.

 xen/arch/x86/hvm/vmsi.c | 22 +++++++++++-----------
 xen/include/xen/delay.h |  8 ++++++--
 2 files changed, 17 insertions(+), 13 deletions(-)

--
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [XEN PATCH 1/2] x86/vmsi: rename variables to address MISRA C:2012 Rule 5.3
  2023-08-09  7:55 [XEN PATCH 0/2] xen: address MISRA C:2012 Rule 5.3 Nicola Vetrini
@ 2023-08-09  7:55 ` Nicola Vetrini
  2023-08-09 12:45   ` Jan Beulich
  2023-08-09  7:55 ` [XEN PATCH 2/2] xen/delay: " Nicola Vetrini
  1 sibling, 1 reply; 8+ messages in thread
From: Nicola Vetrini @ 2023-08-09  7:55 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Nicola Vetrini, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Wei Liu

The local variables 'irq_desc' shadow the homonymous global variable,
declared in 'xen/arch/x86/include/asm/irq.h', therefore they are renamed
'irqd' for consistency.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/arch/x86/hvm/vmsi.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
index 3cd4923060..128f236362 100644
--- a/xen/arch/x86/hvm/vmsi.c
+++ b/xen/arch/x86/hvm/vmsi.c
@@ -462,7 +462,7 @@ static void del_msixtbl_entry(struct msixtbl_entry *entry)
 
 int msixtbl_pt_register(struct domain *d, struct pirq *pirq, uint64_t gtable)
 {
-    struct irq_desc *irq_desc;
+    struct irq_desc *irqd;
     struct msi_desc *msi_desc;
     struct pci_dev *pdev;
     struct msixtbl_entry *entry, *new_entry;
@@ -482,14 +482,14 @@ int msixtbl_pt_register(struct domain *d, struct pirq *pirq, uint64_t gtable)
     if ( !new_entry )
         return -ENOMEM;
 
-    irq_desc = pirq_spin_lock_irq_desc(pirq, NULL);
-    if ( !irq_desc )
+    irqd = pirq_spin_lock_irq_desc(pirq, NULL);
+    if ( !irqd )
     {
         xfree(new_entry);
         return r;
     }
 
-    msi_desc = irq_desc->msi_desc;
+    msi_desc = irqd->msi_desc;
     if ( !msi_desc )
         goto out;
 
@@ -508,7 +508,7 @@ found:
     r = 0;
 
 out:
-    spin_unlock_irq(&irq_desc->lock);
+    spin_unlock_irq(&irqd->lock);
     xfree(new_entry);
 
     if ( !r )
@@ -533,7 +533,7 @@ out:
 
 void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
 {
-    struct irq_desc *irq_desc;
+    struct irq_desc *irqd;
     struct msi_desc *msi_desc;
     struct pci_dev *pdev;
     struct msixtbl_entry *entry;
@@ -544,11 +544,11 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
     if ( !msixtbl_initialised(d) )
         return;
 
-    irq_desc = pirq_spin_lock_irq_desc(pirq, NULL);
-    if ( !irq_desc )
+    irqd = pirq_spin_lock_irq_desc(pirq, NULL);
+    if ( !irqd )
         return;
 
-    msi_desc = irq_desc->msi_desc;
+    msi_desc = irqd->msi_desc;
     if ( !msi_desc )
         goto out;
 
@@ -559,14 +559,14 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
             goto found;
 
 out:
-    spin_unlock_irq(&irq_desc->lock);
+    spin_unlock_irq(&irqd->lock);
     return;
 
 found:
     if ( !atomic_dec_and_test(&entry->refcnt) )
         del_msixtbl_entry(entry);
 
-    spin_unlock_irq(&irq_desc->lock);
+    spin_unlock_irq(&irqd->lock);
 }
 
 void msixtbl_init(struct domain *d)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [XEN PATCH 2/2] xen/delay: address MISRA C:2012 Rule 5.3.
  2023-08-09  7:55 [XEN PATCH 0/2] xen: address MISRA C:2012 Rule 5.3 Nicola Vetrini
  2023-08-09  7:55 ` [XEN PATCH 1/2] x86/vmsi: rename variables to " Nicola Vetrini
@ 2023-08-09  7:55 ` Nicola Vetrini
  2023-08-09 11:10   ` Julien Grall
  2023-08-09 13:56   ` Luca Fancellu
  1 sibling, 2 replies; 8+ messages in thread
From: Nicola Vetrini @ 2023-08-09  7:55 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Nicola Vetrini, Andrew Cooper, George Dunlap,
	Jan Beulich, Julien Grall, Wei Liu

The variable 'msec' declared in the macro shadows the local
variable in 'ehci_dbgp_bios_handoff', but to prevent any
future clashes with other functions the macro is converted to
a static inline function.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/include/xen/delay.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/include/xen/delay.h b/xen/include/xen/delay.h
index 9d70ef035f..9150226271 100644
--- a/xen/include/xen/delay.h
+++ b/xen/include/xen/delay.h
@@ -4,7 +4,11 @@
 /* Copyright (C) 1993 Linus Torvalds */
 
 #include <asm/delay.h>
-#define mdelay(n) (\
-	{unsigned long msec=(n); while (msec--) udelay(1000);})
+
+static inline void mdelay(unsigned long msec)
+{
+    while ( msec-- )
+        udelay(1000);
+}
 
 #endif /* defined(_LINUX_DELAY_H) */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [XEN PATCH 2/2] xen/delay: address MISRA C:2012 Rule 5.3.
  2023-08-09  7:55 ` [XEN PATCH 2/2] xen/delay: " Nicola Vetrini
@ 2023-08-09 11:10   ` Julien Grall
  2023-08-09 13:56   ` Luca Fancellu
  1 sibling, 0 replies; 8+ messages in thread
From: Julien Grall @ 2023-08-09 11:10 UTC (permalink / raw)
  To: Nicola Vetrini, xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Andrew Cooper, George Dunlap, Jan Beulich, Wei Liu

Hi Nicola,

On 09/08/2023 08:55, Nicola Vetrini wrote:
> The variable 'msec' declared in the macro shadows the local
> variable in 'ehci_dbgp_bios_handoff', but to prevent any
> future clashes with other functions the macro is converted to
> a static inline function.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [XEN PATCH 1/2] x86/vmsi: rename variables to address MISRA C:2012 Rule 5.3
  2023-08-09  7:55 ` [XEN PATCH 1/2] x86/vmsi: rename variables to " Nicola Vetrini
@ 2023-08-09 12:45   ` Jan Beulich
  2023-08-10 15:27     ` Nicola Vetrini
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2023-08-09 12:45 UTC (permalink / raw)
  To: Nicola Vetrini
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Andrew Cooper, Roger Pau Monné, Wei Liu,
	xen-devel

On 09.08.2023 09:55, Nicola Vetrini wrote:
> The local variables 'irq_desc' shadow the homonymous global variable,
> declared in 'xen/arch/x86/include/asm/irq.h', therefore they are renamed
> 'irqd' for consistency.

Perhaps with "for consistency" dropped (or else clarified what this
is to be consistent with) ...

> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [XEN PATCH 2/2] xen/delay: address MISRA C:2012 Rule 5.3.
  2023-08-09  7:55 ` [XEN PATCH 2/2] xen/delay: " Nicola Vetrini
  2023-08-09 11:10   ` Julien Grall
@ 2023-08-09 13:56   ` Luca Fancellu
  2023-08-09 14:09     ` Nicola Vetrini
  1 sibling, 1 reply; 8+ messages in thread
From: Luca Fancellu @ 2023-08-09 13:56 UTC (permalink / raw)
  To: Nicola Vetrini
  Cc: Xen-devel, Stefano Stabellini, michal.orzel@amd.com,
	xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com,
	consulting@bugseng.com, Andrew Cooper, George Dunlap, Jan Beulich,
	Julien Grall, Wei Liu



> On 9 Aug 2023, at 08:55, Nicola Vetrini <nicola.vetrini@bugseng.com> wrote:
> 
> The variable 'msec' declared in the macro shadows the local
> variable in 'ehci_dbgp_bios_handoff', but to prevent any
> future clashes with other functions the macro is converted to
> a static inline function.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
> xen/include/xen/delay.h | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/include/xen/delay.h b/xen/include/xen/delay.h
> index 9d70ef035f..9150226271 100644
> --- a/xen/include/xen/delay.h
> +++ b/xen/include/xen/delay.h
> @@ -4,7 +4,11 @@
> /* Copyright (C) 1993 Linus Torvalds */
> 
> #include <asm/delay.h>
> -#define mdelay(n) (\
> - {unsigned long msec=(n); while (msec--) udelay(1000);})
> +
> +static inline void mdelay(unsigned long msec)
> +{
> +    while ( msec-- )

Does misra allows to modify the function parameters? (Truly asking because IDK)

> +        udelay(1000);
> +}
> 
> #endif /* defined(_LINUX_DELAY_H) */
> -- 
> 2.34.1
> 
> 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [XEN PATCH 2/2] xen/delay: address MISRA C:2012 Rule 5.3.
  2023-08-09 13:56   ` Luca Fancellu
@ 2023-08-09 14:09     ` Nicola Vetrini
  0 siblings, 0 replies; 8+ messages in thread
From: Nicola Vetrini @ 2023-08-09 14:09 UTC (permalink / raw)
  To: Luca Fancellu
  Cc: Xen-devel, Stefano Stabellini, michal.orzel, xenia.ragiadakou,
	ayan.kumar.halder, consulting, Andrew Cooper, George Dunlap,
	Jan Beulich, Julien Grall, Wei Liu

On 09/08/2023 15:56, Luca Fancellu wrote:
>> On 9 Aug 2023, at 08:55, Nicola Vetrini <nicola.vetrini@bugseng.com> 
>> wrote:
>> 
>> The variable 'msec' declared in the macro shadows the local
>> variable in 'ehci_dbgp_bios_handoff', but to prevent any
>> future clashes with other functions the macro is converted to
>> a static inline function.
>> 
>> No functional change.
>> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> ---
>> xen/include/xen/delay.h | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/xen/include/xen/delay.h b/xen/include/xen/delay.h
>> index 9d70ef035f..9150226271 100644
>> --- a/xen/include/xen/delay.h
>> +++ b/xen/include/xen/delay.h
>> @@ -4,7 +4,11 @@
>> /* Copyright (C) 1993 Linus Torvalds */
>> 
>> #include <asm/delay.h>
>> -#define mdelay(n) (\
>> - {unsigned long msec=(n); while (msec--) udelay(1000);})
>> +
>> +static inline void mdelay(unsigned long msec)
>> +{
>> +    while ( msec-- )
> 
> Does misra allows to modify the function parameters? (Truly asking 
> because IDK)
> 

I checked: there's an advisory (R17.8) that disallows this, but since 
advisories (apart from
a couple of selected ones) are not taken into consideration for 
compliance, so it's not a big deal.
Even less so since it's not a pointer type.

-- 
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [XEN PATCH 1/2] x86/vmsi: rename variables to address MISRA C:2012 Rule 5.3
  2023-08-09 12:45   ` Jan Beulich
@ 2023-08-10 15:27     ` Nicola Vetrini
  0 siblings, 0 replies; 8+ messages in thread
From: Nicola Vetrini @ 2023-08-10 15:27 UTC (permalink / raw)
  To: Jan Beulich
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Andrew Cooper, Roger Pau Monné, Wei Liu,
	xen-devel

On 09/08/2023 14:45, Jan Beulich wrote:
> On 09.08.2023 09:55, Nicola Vetrini wrote:
>> The local variables 'irq_desc' shadow the homonymous global variable,
>> declared in 'xen/arch/x86/include/asm/irq.h', therefore they are 
>> renamed
>> 'irqd' for consistency.
> 
> Perhaps with "for consistency" dropped (or else clarified what this
> is to be consistent with) ...
> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Jan

Good point.

-- 
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-10 15:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09  7:55 [XEN PATCH 0/2] xen: address MISRA C:2012 Rule 5.3 Nicola Vetrini
2023-08-09  7:55 ` [XEN PATCH 1/2] x86/vmsi: rename variables to " Nicola Vetrini
2023-08-09 12:45   ` Jan Beulich
2023-08-10 15:27     ` Nicola Vetrini
2023-08-09  7:55 ` [XEN PATCH 2/2] xen/delay: " Nicola Vetrini
2023-08-09 11:10   ` Julien Grall
2023-08-09 13:56   ` Luca Fancellu
2023-08-09 14:09     ` Nicola Vetrini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.