Message ID | d9342b2a0390cf3128487cfe885940682bf9442e.1711118582.git.nicola.vetrini@bugseng.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | address some violations of MISRA C Rule 20.7 | expand |
On 22.03.2024 17:02, Nicola Vetrini wrote: > 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> Acked-by: Jan Beulich <jbeulich@suse.com> > --- a/xen/include/public/arch-x86/xen.h > +++ b/xen/include/public/arch-x86/xen.h > @@ -36,7 +36,7 @@ > #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name > #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) > #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) > -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) > +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = (val); } while (0) > #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) > > #if defined(__i386__) Would have been nice though to do the same thing for Arm at the same time. PPC and RISC-V already have "val" parenthesized there. Jan
On 2024-03-26 11:15, Jan Beulich wrote: > On 22.03.2024 17:02, Nicola Vetrini wrote: >> 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> > > Acked-by: Jan Beulich <jbeulich@suse.com> > >> --- a/xen/include/public/arch-x86/xen.h >> +++ b/xen/include/public/arch-x86/xen.h >> @@ -36,7 +36,7 @@ >> #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name >> #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) >> #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) >> -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } >> while (0) >> +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = (val); } >> while (0) >> #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, >> val) >> >> #if defined(__i386__) > > Would have been nice though to do the same thing for Arm at the same > time. > PPC and RISC-V already have "val" parenthesized there. > > Jan Ok, no problem.
On 22.03.2024 17:02, Nicola Vetrini wrote: > 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> Btw, I've taken the liberty to drop the (secondary) hvm: prefix from the subject; I can't ... > --- a/xen/include/public/arch-x86/xen.h > +++ b/xen/include/public/arch-x86/xen.h > @@ -36,7 +36,7 @@ > #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name > #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) > #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) > -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) > +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = (val); } while (0) > #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) ... spot anything HVM-specific in this change. Jan
diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index c0f4551247f4..a9a87d9b50de 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -36,7 +36,7 @@ #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = (val); } while (0) #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) #if defined(__i386__)
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/include/public/arch-x86/xen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)