[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



On 03/08/2023 11:17, Jan Beulich wrote:
On 02.08.2023 16:38, Nicola Vetrini wrote:
--- 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;

What use is "break" after "return"? IOW rather than adding code here,
imo a line wants removing.

Jan

The "return false" after the switch would still be unreachable. The reasoning behind preserving the break is mainly MISRA Rule 16.3: "An unconditional break statement shall terminate every switch-clause", which has not yet been considered for adoption, but might be in future discussions, leading to putting back the break here.

--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)



 


Rackspace

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