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

Re: [XEN PATCH 3/7] xen/arm: address MISRA C:2012 Rule 2.1


  • To: Julien Grall <julien@xxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 11 Dec 2023 14:06:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ki6pc6WA00/Ip1SDCjI5lfGfFFY+R+iOGMs3/8kABJA=; b=MSaZl9MTaEbB4tn51nDujHl4TIqBMLgYGqmASOu9RVeWaqvD/I1ZcKNDintBfSkW2Xwo4/L9iwLnF8/E08p/OrqF7UjuY5to6zGDfdzsqM7ukRqotWLWGEuo3lfgk5TLnYUCi1xEOtjtoSTHOsCaCao943GIfsCS/virRAHQZUjZgSiHj6T4RvghEUXL2Xz/uT6shSd3Vskh/FqCLGcB0krh5s7DDCdJovUSfrS4rAKWFrzz5IJ8t2tYsGehKv+U7O1gZNC0TJqmiG2zjTqP0xH67gYyIk0lKVY2Vom16kWzv1Fn/vn1CiBROc2MyVrKT/vtJcEnzW1LdN6psSOOrg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPbkt7hiRez5ewAOK8zRxjnFEU7M+Pn0TOBCROzUEcgJgZF6xgVvYL5efIF1c5lEG6uvI0l8y/MHYwQyoqm+I2hs67fjLzNTUK+ddYEKIstp4cBhuBDxm7FLbrYHCT6MDWC78V4ZaweWZWFVaQhE2jtMS3IdpFwnTyH0utdoGO0YqV+51cGbCADg6v0wuj+3U2vG0dwhdILjI4wcCt4/f5ei53JimWnfu40GarzTDol4qq/AD1fFXPnLBVNpsWMiCkKFpJLyoEdW7nd6ICV8d/YaLD875JGExhA5v3YcusPYYp1kEKwCwLmW0xdFmmqACWmlINKMkcj1YIpnLQn0Vg==
  • Cc: <consulting@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 11 Dec 2023 13:07:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 11/12/2023 13:29, Julien Grall wrote:
> 
> 
> Hi,
> 
> On 11/12/2023 10:30, Nicola Vetrini wrote:
>> The "return 1;" statements at the end of some cases in the switch
>> of function 'vgic_v3_its_mmio_write' in 'vcig-v3-its.c' cause the
>> unreachability of the "return 1;" statement after the switch, thus
>> violating MISRA C:2012 Rule 2.1:
>> "A project shall not contain unreachable code".
>>
>> The same is true for the switch in 'arch_memory_op' from
>> 'xen/arch/arm/mm.c'.
> 
> For both cases, I actually much prefer the "return" version in the
> cases. In particular for the vGIC emulation the switch is quite large
> and it would not be trivial to know what happens after the break.
Because of this...

> 
> IOW, I would much prefer if we remove the "return ..." outside of the
> switch.
wouldn't it be better to add ASSERT_UNREACHABLE() before this return instead of 
removing it?
This is what we have in e.g. vpl011 and it prevents mistakes.

~Michal



 


Rackspace

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