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

Re: [XEN PATCH 10/11] xen/sched: add ASSERT_UNREACHABLE() to address MISRA C:2012 Rule 2.1



Hi,

On 02/08/2023 15:38, Nicola Vetrini wrote:
The break statement after the return statement is definitely unreachable.
As such, an call to the ASSERT_UNREACHABLE() macro is added to signal
the intentionality of such construct.

How about using unreachable() rather than ASSERT_UNREACHABLE()? The main difference is the later will hint the compiler that the code cannot be reached and will not crash Xen in debug build (this could be changed).


Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
---
The break in the clause is mandated by Required Rule 16.3, which is
not yet an accepted rule for Xen, but may be in the future.
---
  xen/common/sched/core.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 022f548652..fcee902b4e 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2233,6 +2233,7 @@ static bool sched_tasklet_check_cpu(unsigned int cpu)
          /* fallthrough */
      case TASKLET_enqueued|TASKLET_scheduled:
          return true;
+        ASSERT_UNREACHABLE();
          break;
      case TASKLET_scheduled:
          clear_bit(_TASKLET_scheduled, tasklet_work);

Cheers,

--
Julien Grall



 


Rackspace

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