Xen-Devel Archive mirror
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: xen-devel@lists.xenproject.org, nicola.vetrini@bugseng.com
Cc: sstabellini@kernel.org, michal.orzel@amd.com,
	xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com,
	consulting@bugseng.com, bertrand.marquis@arm.com, julien@xen.org,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [XEN PATCH 05/10] xen/spinlock: address violations of MISRA C Rule 20.7
Date: Tue, 23 Apr 2024 17:12:47 +0200	[thread overview]
Message-ID: <620466b08df1efb706e757aee05a8d7f7e6e8f4a.1713885065.git.nicola.vetrini@bugseng.com> (raw)
In-Reply-To: <cover.1713885065.git.nicola.vetrini@bugseng.com>

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/spinlock.c      | 2 +-
 xen/include/xen/spinlock.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
index 5aa9ba618859..558ea7ac3518 100644
--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -269,7 +269,7 @@ void spin_debug_disable(void)
         profile->lock_cnt++;                                                 \
     }
 #define LOCK_PROFILE_VAR(var, val)    s_time_t var = (val)
-#define LOCK_PROFILE_BLOCK(var)       var = var ? : NOW()
+#define LOCK_PROFILE_BLOCK(var)       (var) = (var) ? : NOW()
 #define LOCK_PROFILE_BLKACC(tst, val)                                        \
     if ( tst )                                                               \
     {                                                                        \
diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h
index 18793c5e29cb..8825affb25ca 100644
--- a/xen/include/xen/spinlock.h
+++ b/xen/include/xen/spinlock.h
@@ -141,7 +141,7 @@ struct lock_profile_qhead {
         }                                                                     \
         prof->name = #l;                                                      \
         prof->ptr.lockptr = &(s)->l;                                          \
-        prof->is_rlock = isr;                                                 \
+        prof->is_rlock = (isr);                                               \
         prof->next = (s)->profile_head.elem_q;                                \
         (s)->profile_head.elem_q = prof;                                      \
     } while( 0 )
-- 
2.34.1



  parent reply	other threads:[~2024-04-23 15:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 15:12 [XEN PATCH 00/10] Address violations of MISRA C Rule 20.7 Nicola Vetrini
2024-04-23 15:12 ` [XEN PATCH 01/10] libelf: address " Nicola Vetrini
2024-04-24  7:19   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 02/10] xen/page-defs: address violation " Nicola Vetrini
2024-04-24  7:20   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 03/10] automation/eclair_analysis: deviate macro count_args_ for MISRA " Nicola Vetrini
2024-04-25  0:28   ` Stefano Stabellini
2024-04-29 12:18     ` Nicola Vetrini
2024-05-01 19:54       ` Stefano Stabellini
2024-05-15  7:09         ` Nicola Vetrini
2024-05-15  7:15           ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 04/10] drivers: char: address violation of MISRA C " Nicola Vetrini
2024-04-24  7:23   ` Jan Beulich
2024-04-24 10:07     ` Nicola Vetrini
2024-04-23 15:12 ` Nicola Vetrini [this message]
2024-04-24  7:25   ` [XEN PATCH 05/10] xen/spinlock: address violations " Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 06/10] x86/pci: address violation " Nicola Vetrini
2024-04-24  7:26   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 07/10] x86/acpi: power: address violations of MISRA " Nicola Vetrini
2024-04-24  7:26   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 08/10] x86/hvm: hpet: address violations of MISRA C " Nicola Vetrini
2024-04-24  7:28   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 09/10] x86/debugreg: address violation " Nicola Vetrini
2024-04-24  7:28   ` Jan Beulich
2024-04-23 15:12 ` [XEN PATCH 10/10] x86/mm: address violations " Nicola Vetrini
2024-04-24  7:29   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=620466b08df1efb706e757aee05a8d7f7e6e8f4a.1713885065.git.nicola.vetrini@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ayan.kumar.halder@amd.com \
    --cc=bertrand.marquis@arm.com \
    --cc=consulting@bugseng.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenia.ragiadakou@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).