Message ID | 3418c09bb8c4ceeceb66334191adfad190954f56.1709219010.git.nicola.vetrini@bugseng.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | address some violations of MISRA C Rule 20.7 | expand |
On 29.02.2024 16:27, Nicola Vetrini wrote: > --- a/xen/common/perfc.c > +++ b/xen/common/perfc.c > @@ -10,10 +10,10 @@ > #include <public/sysctl.h> > #include <asm/perfc.h> > > -#define PERFCOUNTER( var, name ) { name, TYPE_SINGLE, 0 }, > -#define PERFCOUNTER_ARRAY( var, name, size ) { name, TYPE_ARRAY, size }, > -#define PERFSTATUS( var, name ) { name, TYPE_S_SINGLE, 0 }, > -#define PERFSTATUS_ARRAY( var, name, size ) { name, TYPE_S_ARRAY, size }, > +#define PERFCOUNTER( var, name ) { (name), TYPE_SINGLE, 0 }, > +#define PERFCOUNTER_ARRAY( var, name, size ) { (name), TYPE_ARRAY, (size) }, > +#define PERFSTATUS( var, name ) { (name), TYPE_S_SINGLE, 0 }, > +#define PERFSTATUS_ARRAY( var, name, size ) { (name), TYPE_S_ARRAY, (size) }, Same question as for patch 4. Plus if this needed touching, then the stray blanks immediately inside the parentheses would please be dropped as well. Jan
On 2024-02-29 17:42, Jan Beulich wrote: > On 29.02.2024 16:27, Nicola Vetrini wrote: >> --- a/xen/common/perfc.c >> +++ b/xen/common/perfc.c >> @@ -10,10 +10,10 @@ >> #include <public/sysctl.h> >> #include <asm/perfc.h> >> >> -#define PERFCOUNTER( var, name ) { name, TYPE_SINGLE, 0 >> }, >> -#define PERFCOUNTER_ARRAY( var, name, size ) { name, TYPE_ARRAY, >> size }, >> -#define PERFSTATUS( var, name ) { name, TYPE_S_SINGLE, >> 0 }, >> -#define PERFSTATUS_ARRAY( var, name, size ) { name, TYPE_S_ARRAY, >> size }, >> +#define PERFCOUNTER( var, name ) { (name), TYPE_SINGLE, >> 0 }, >> +#define PERFCOUNTER_ARRAY( var, name, size ) { (name), TYPE_ARRAY, >> (size) }, >> +#define PERFSTATUS( var, name ) { (name), >> TYPE_S_SINGLE, 0 }, >> +#define PERFSTATUS_ARRAY( var, name, size ) { (name), TYPE_S_ARRAY, >> (size) }, > > Same question as for patch 4. Plus if this needed touching, then the > stray > blanks immediately inside the parentheses would please be dropped as > well. > Noted
diff --git a/xen/common/perfc.c b/xen/common/perfc.c index 7400667bf0c4..02f4fc8fe032 100644 --- a/xen/common/perfc.c +++ b/xen/common/perfc.c @@ -10,10 +10,10 @@ #include <public/sysctl.h> #include <asm/perfc.h> -#define PERFCOUNTER( var, name ) { name, TYPE_SINGLE, 0 }, -#define PERFCOUNTER_ARRAY( var, name, size ) { name, TYPE_ARRAY, size }, -#define PERFSTATUS( var, name ) { name, TYPE_S_SINGLE, 0 }, -#define PERFSTATUS_ARRAY( var, name, size ) { name, TYPE_S_ARRAY, size }, +#define PERFCOUNTER( var, name ) { (name), TYPE_SINGLE, 0 }, +#define PERFCOUNTER_ARRAY( var, name, size ) { (name), TYPE_ARRAY, (size) }, +#define PERFSTATUS( var, name ) { (name), TYPE_S_SINGLE, 0 }, +#define PERFSTATUS_ARRAY( var, name, size ) { (name), TYPE_S_ARRAY, (size) }, static const struct { const char *name; enum { TYPE_SINGLE, TYPE_ARRAY,
MISRA C Rule 20.7 states: "Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses". Therefore, some macro definitions should gain additional parentheses to ensure that all current and future users will be safe with respect to expansions that can possibly alter the semantics of the passed-in macro parameter. No functional change. Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com> --- xen/common/perfc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)