[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/12] xen: Bracket uses of macro parameters
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
- Date: Wed, 25 Feb 2026 17:34:39 +0100
- Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
- Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1772037279; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=6kHTQwT6E5aPdQgdrwEfnEfD2oRdXwzFPDU/nBMaU4s=; b=P0/YYp0sqHYxe2DOUYX2+TFLVb8hsCR923sfJUKLYKzXnwDPeiAUoIKHsPF+bqhhimdG nkVb8HARD3IcWv5VmubAGUbpYPL1cahLkF3m7FCeuiTz1dWDZAkmNpKIhSW5O8d5oWr1x 62mrqicY7khEHyb//RX9/CuNf2aQT8+X7qgpLOUCXBgzILAK3NdbuX50OiTtGtCS7KONR EafyC0F0dgm0QIVjhG7E7KMRmigxPeAx0gPdLBRaE49gm+1n7DWcQDywmCoNW8J78m0Zx cfDhW1hhY0OFSh8DibjPmDJ5R7cSDdyITxNOsVgwaWLDLOv8J5FbF6cWxqDoxs0TB30Pj Fem5JVG1UDQHqaLdG9JRlpUix5miX5ndFJ7E515T6CzVW9RFaheI/8346q3rc8oCqQ2pS FCKmdBzCjWAeYyLhW/2kyh+o+BQZ6OLqkaRAC8WwqxExG1sEx/nFLfpBU2BxHE/5l3zIY ECh6UiQ625FU1Xlz4ADf77g1ASokkpaq+QlhKbH4hDQQwLZGsVMhUy4LVXq6VWKJPJ/nC rHRjrHvxySKc3PeUYo5xhYNckNDppcnKVPBkdxTpBcJehd+uuX7AI9X20dNJF6f7jdp4o u73jw/yYZwXFZFU7C5iC+2FT1cqijjs/yT/4VqqJVkwm3mTKnmS0YTe4MgQux/8=
- Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1772037279; b=h4o42yMSIKhtOfTa0n/032J3+CTvI3wQgJnv3ZYgWCWrzanZ2rU+iEZ6CUmEJiNkmSW4 Ngi3Wnu0HDnPFHC0CBgHj72S+zO8jurNXuapGEoNXs5aY975UP7+szyhljum+b4SXdzXC Qswxg61qL/DDef/uZdWr657PF7AyFk0nA9J2BlsHTBAlXaWUvuWyeKFeI1p38V0XaF+Zw Dh2OkbXU6OSnvYv1qOiLANBPwYvFctVGMueugOcDtmx9KKZhnHAo0G+xUi/LK78QUSNr8 ZqCCjVddI5x0+dn2z45CCV2OJcn9/F/BYuYpP8ytLBVDB1WP2FFNIY8OhJYudiPb1fnLP kJ8wECU7X9RRf1sDmaHHZZGcRxLuF3t6f1fdg3cCfx3nfgiv29dHZI1riNG2s1V+1JWGI 1drBJoEetxA6lQsKaiZi2rPE4oyn8sVdnYthOYeCTjlpPZd9gzZimUgMiz9C8Whf9q0sh y+G/k6Xx6/oEYiSLSbMVhcPBxhiwnjKZ9mcQa1AIaUIeosnyYiPgfM0R93GzXsyhPrw+v 8VGcVJhOgEPle76H+eU2d6zFFv6HbQ4BrWJ1KIvzhDcnye+oFgPSrLND1GXkVb67Bgkjk FfjPaxLruH9BM9nyTvKs4xe9nDdV2yVbe/lN4Q5zEKKduHWV0FJAjhl2pfNZMlY=
- Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "consulting @ bugseng . com" <consulting@xxxxxxxxxxx>
- Delivery-date: Wed, 25 Feb 2026 16:34:46 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2026-02-25 17:05, Andrew Cooper wrote:
On 20/02/2026 10:45 pm, Nicola Vetrini wrote:
On 2026-02-20 22:46, Andrew Cooper wrote:
Fixing Rule 20.7 violations.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Thanks.
diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 7446533c8cfb..63473925cafb 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -664,9 +664,10 @@ static inline int
livepatch_check_expectations(const struct payload *payload)
const struct livepatch_elf_sec *__sec =
livepatch_elf_sec_by_name(elf, section_name); \
if ( !__sec
)
\
break;
\
- if ( !section_ok(elf, __sec, sizeof(*hook)) ||
__sec->sec->sh_size != sizeof(*hook) ) \
+ if ( !section_ok(elf, __sec, sizeof(*(hook)))
|| \
+ __sec->sec->sh_size != sizeof(*(hook))
) \
return
-EINVAL;
\
- hook =
__sec->addr;
\
+ (hook) =
__sec->addr;
\
This is not strictly needed, if not for consistency.
That explains why my first try didn't succeed. But, why is it that
only
MISRA only cares about bracketing for rvalues, not lvalues ?
It was actually asked by Xen maintainers to introduce this special case
on the grounds that it is extremely unlikely to result in an operator
precedence mishap that leads to incorrect expansion. See below:
-doc_begin="Code violating Rule 20.7 is safe when macro parameters are
used: (1)
as function arguments; (2) as macro arguments; (3) as array indices; (4)
as lhs
in assignments; (5) as initializers, possibly designated, in initalizer
lists;
(6) as the constant expression in a switch clause label."
-config=MC3A2.R20.7,expansion_context=
[...]
--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
|