diff mbox series

[XEN,v2,2/5] xen/delay: address MISRA C:2012 Rule 5.3.

Message ID 27631ba28fc6f47095fe0db3f8ee2cd87de616ed.1691492441.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series x86: address MISRA C:2012 Rule 5.3 | expand

Commit Message

Nicola Vetrini Aug. 8, 2023, 11:08 a.m. UTC
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>
---
Changes in v2:
- Switched to a static inline function, as suggested by Julien
---
 xen/include/xen/delay.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jan Beulich Aug. 8, 2023, 1:56 p.m. UTC | #1
On 08.08.2023 13:08, Nicola Vetrini wrote:
> --- a/xen/include/xen/delay.h
> +++ b/xen/include/xen/delay.h
> @@ -4,7 +4,12 @@
>  /* 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 n)
> +{
> +    unsigned long msec=n;
> +    while ( msec-- )
> +        udelay(1000);
> +}

Nit: Style (blanks around = and blank line between declaration and
statement). If need be I guess this again can be taken care of while
committing. With the adjustments
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
Jan Beulich Aug. 8, 2023, 1:57 p.m. UTC | #2
On 08.08.2023 15:56, Jan Beulich wrote:
> On 08.08.2023 13:08, Nicola Vetrini wrote:
>> --- a/xen/include/xen/delay.h
>> +++ b/xen/include/xen/delay.h
>> @@ -4,7 +4,12 @@
>>  /* 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 n)
>> +{
>> +    unsigned long msec=n;
>> +    while ( msec-- )
>> +        udelay(1000);
>> +}
> 
> Nit: Style (blanks around = and blank line between declaration and
> statement). If need be I guess this again can be taken care of while
> committing. With the adjustments
> Acked-by: Jan Beulich <jbeulich@suse.com>

Actually - why have a local variable here at all? Just name the
function parameter "msec".

Jan
diff mbox series

Patch

diff --git a/xen/include/xen/delay.h b/xen/include/xen/delay.h
index 9d70ef035f..6ecee851f6 100644
--- a/xen/include/xen/delay.h
+++ b/xen/include/xen/delay.h
@@ -4,7 +4,12 @@ 
 /* 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 n)
+{
+    unsigned long msec=n;
+    while ( msec-- )
+        udelay(1000);
+}
 
 #endif /* defined(_LINUX_DELAY_H) */