[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm64: sysreg.h: Fix MISRA C 2012 Rule 20.7 violation




On 7/28/22 17:34, Julien Grall wrote:
Hi,

On 28/07/2022 15:20, Jan Beulich wrote:
On 28.07.2022 15:56, Julien Grall wrote:
On 28/07/2022 14:49, Xenia Ragiadakou wrote:
--- a/xen/arch/arm/include/asm/arm64/sysregs.h
+++ b/xen/arch/arm/include/asm/arm64/sysregs.h
@@ -461,7 +461,7 @@
   /* Access to system registers */
   #define WRITE_SYSREG64(v, name) do {                    \
-    uint64_t _r = v;                                    \
+    uint64_t _r = (v);                                              \

I am failing to see why the parentheses are necessary here. Could you
give an example where the lack of them would end up to different code?

I think it is merely good practice to parenthesize the right sides of =.
Indeed with assignment operators having second to lowest precedence, and
with comma (the lowest precedence one) requiring parenthesization at the
macro invocation site, there should be no real need for parentheses here.

I am not really happy with adding those parentheses because they are pointless. But if there are a consensus to use it, then the commit message should be updated to clarify this is just here to please MISRA (to me "need" implies it would be bug).

The parentheses are not pointless if the intention is v to be used as an expression to the assignment. If this is not the intended usage for v, then the rule does not apply anyway.

--
Xenia



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.