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 |
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
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 --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) */
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(-)