All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: xen-devel@lists.xenproject.org
Cc: consulting@bugseng.com,
	Nicola Vetrini <nicola.vetrini@bugseng.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [XEN PATCH v2 4/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed
Date: Mon, 18 Dec 2023 11:17:30 +0100	[thread overview]
Message-ID: <02070d1bb4bfc0e88d548a529bef8bedab5b3488.1702891792.git.nicola.vetrini@bugseng.com> (raw)
In-Reply-To: <cover.1702891792.git.nicola.vetrini@bugseng.com>

The statements after a call to the noreturn function 'do_unexpected_trap'
can't be reached, thus violating MISRA C:2012 Rule 2.1
("A project shall not contain unreachable code.").
ASSERT_UNREACHABLE() is used to signal that the unreachable break-s are used as
a defensive coding measure to prevent inadvertent fallthrough.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
Changes in v2:
- Use ASSERT_UNREACHABLE() to prevent mistakes.
---
 xen/arch/arm/traps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 3784e8276ef6..77220ba0927a 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2152,6 +2152,7 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs)
     case HSR_EC_SVE:
         /* An SVE exception is a bug somewhere in hypervisor code */
         do_unexpected_trap("SVE trap at EL2", regs);
+        ASSERT_UNREACHABLE();
         break;
 #endif
     case HSR_EC_DATA_ABORT_CURR_EL:
@@ -2171,7 +2172,7 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs)
             dump_hyp_walk(get_hfar(is_data));
 
         do_unexpected_trap(fault, regs);
-
+        ASSERT_UNREACHABLE();
         break;
     }
     default:
-- 
2.34.1


  parent reply	other threads:[~2023-12-18 10:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 10:17 [XEN PATCH v2 0/7] address violations of MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-18 10:17 ` [XEN PATCH v2 1/7] xen/shutdown: address " Nicola Vetrini
2023-12-19  1:31   ` Stefano Stabellini
2023-12-18 10:17 ` [XEN PATCH v2 2/7] x86/mm: " Nicola Vetrini
2023-12-19  1:33   ` Stefano Stabellini
2023-12-19 10:56   ` Jan Beulich
2023-12-18 10:17 ` [XEN PATCH v2 3/7] xen/arm: " Nicola Vetrini
2023-12-19  1:35   ` Stefano Stabellini
2023-12-18 10:17 ` Nicola Vetrini [this message]
2023-12-19  1:36   ` [XEN PATCH v2 4/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed Stefano Stabellini
2023-12-18 10:17 ` [XEN PATCH v2 5/7] x86/platform: removed break to address MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-19  1:37   ` Stefano Stabellini
2023-12-18 10:17 ` [XEN PATCH v2 6/7] xen/arm: vcpreg: address violation of MISRA C " Nicola Vetrini
2023-12-19  1:39   ` Stefano Stabellini
2023-12-18 10:17 ` [XEN PATCH v2 7/7] automation/eclair_analysis: avoid violation of MISRA " Nicola Vetrini
2023-12-19  1:40   ` Stefano Stabellini
2023-12-19  1:43     ` Stefano Stabellini
2023-12-19  8:00       ` Nicola Vetrini

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=02070d1bb4bfc0e88d548a529bef8bedab5b3488.1702891792.git.nicola.vetrini@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=consulting@bugseng.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.