Message ID | 5be252bfb30682d33aecca11921dcdfcc17f9ae6.1709896401.git.nicola.vetrini@bugseng.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | address some violations of MISRA C Rule 20.7 | expand |
On Fri, 8 Mar 2024, 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> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h index 2c45c462fc63..77fe1e1ba840 100644 --- a/xen/include/xen/bug.h +++ b/xen/include/xen/bug.h @@ -80,7 +80,7 @@ struct bug_frame { [bf_type] "i" (type), \ [bf_ptr] "i" (ptr), \ [bf_msg] "i" (msg), \ - [bf_line_lo] "i" ((line & ((1 << BUG_LINE_LO_WIDTH) - 1)) \ + [bf_line_lo] "i" (((line) & ((1 << BUG_LINE_LO_WIDTH) - 1)) \ << BUG_DISP_WIDTH), \ [bf_line_hi] "i" (((line) >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH) diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h index 1d7c0216bc80..0a4223833755 100644 --- a/xen/include/xen/init.h +++ b/xen/include/xen/init.h @@ -63,9 +63,9 @@ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); #define presmp_initcall(fn) \ - const static initcall_t __initcall_##fn __init_call("presmp") = fn + const static initcall_t __initcall_##fn __init_call("presmp") = (fn) #define __initcall(fn) \ - const static initcall_t __initcall_##fn __init_call("1") = fn + const static initcall_t __initcall_##fn __init_call("1") = (fn) #define __exitcall(fn) \ static exitcall_t __exitcall_##fn __exit_call = fn
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> --- Changes in v2: - split from an earlier patch --- xen/include/xen/bug.h | 2 +- xen/include/xen/init.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)