From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38107C4332F for ; Wed, 13 Dec 2023 14:44:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.654072.1020711 (Exim 4.92) (envelope-from ) id 1rDQTe-0000VS-4m; Wed, 13 Dec 2023 14:44:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 654072.1020711; Wed, 13 Dec 2023 14:44:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDQTe-0000VL-28; Wed, 13 Dec 2023 14:44:46 +0000 Received: by outflank-mailman (input) for mailman id 654072; Wed, 13 Dec 2023 14:44:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDQTd-0000VD-4B for xen-devel@lists.xenproject.org; Wed, 13 Dec 2023 14:44:45 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 277421bd-99c6-11ee-98e9-6d05b1d4d9a1; Wed, 13 Dec 2023 15:44:44 +0100 (CET) Received: from support.bugseng.com (support.bugseng.com [162.55.131.47]) by support.bugseng.com (Postfix) with ESMTPA id A5E9D4EE0737; Wed, 13 Dec 2023 15:44:43 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 277421bd-99c6-11ee-98e9-6d05b1d4d9a1 MIME-Version: 1.0 Date: Wed, 13 Dec 2023 15:44:43 +0100 From: Nicola Vetrini To: Jan Beulich Cc: Stefano Stabellini , xen-devel@lists.xenproject.org, consulting@bugseng.com, Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: Re: [XEN PATCH 2/7] x86/mm: address MISRA C:2012 Rule 2.1 In-Reply-To: <0ad1d3f5-2a23-4ee9-a6e7-ebb824d2b7d7@suse.com> References: <5913d8871ff6c4f320c521e50e550a64e58d4351.1702283415.git.nicola.vetrini@bugseng.com> <0ad1d3f5-2a23-4ee9-a6e7-ebb824d2b7d7@suse.com> Message-ID: <8a49facc4fbf4d3fefb91b9b5bef3305@bugseng.com> X-Sender: nicola.vetrini@bugseng.com Organization: BUGSENG s.r.l. Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit On 2023-12-12 10:53, Jan Beulich wrote: > On 12.12.2023 10:12, Nicola Vetrini wrote: >> On 2023-12-12 02:42, Stefano Stabellini wrote: >>> On Mon, 11 Dec 2023, Nicola Vetrini wrote: >>>> The "return 0" after the swich statement in 'xen/arch/x86/mm.c' >>>> is unreachable because all switch clauses end with returns. >>>> However, some of them can be substituted with "break"s to allow >>>> the "return 0" outside the switch to be reachable. >>>> >>>> No functional changes. >>> >>> This is correct but makes the code inconsistent. I would either >>> remove >>> the return 0; at the end of arch_memory_op, or do the following: >>> >>> - initialize rc to 0 at the beginning: int rc = 0; >>> - all switch clauses break instead of return; >>> - at the end: return rc; >> >> Given the feedback on the Arm side, the first solution is likely to be >> preferred. > > I wouldn't mind either option, with > - the former ensured to be okay with all compiler versions we (still) > support, I tested a stripped-down version of the switch on godbolt.org (as far back as gcc-4.8.5) and it doesn't complain. It should be tested on a real Xen build, though. > - the latter having the initialize rc to 0 part dropped; imo it's > better > if every case block makes sure to set the intended value explicitly. > This is a lot of churn, I'd rather avoid it. -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)