From nobody Sat Nov 23 04:11:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1710453049; cv=none; d=zohomail.com; s=zohoarc; b=mILYbxs+YGIBqRhN9tukcTTwgrLFqzpXu4gCekalp0R/j4QyFJ+VMbpjt+FkZ4aS4Y0C9D9g4lWj1O2JRDKrbJKiDGdQKkfxdnOuFzunUU567qIbWuYIzVZYnVCDaYwGhDBKi0a5xh/IV7Cs26gBiRAikhPNyGzuZ9NGEqqimVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710453049; h=Content-Type:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pwgK4ClecGppmTjwS0zCZldbFBkFTuuUYHYTZfI4A84=; b=GQlqE+w6dLU/U3VWCv4mJipCdBIoScf9yrAtH5ZLXnBXclKjVXPSFLjUjhfy9NBrxUKVxSHZzt/5rUzLGQwszWI/5A/NX1qE0t2YXjFXNjIZc9kUlQ0u1PFLeFb6jTgNB68mZKtzcfZiSDK9QY+eXPLVAfRnA7nsbDGPWwt8bj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710453049447580.8186873681527; Thu, 14 Mar 2024 14:50:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693500.1081633 (Exim 4.92) (envelope-from ) id 1rksy5-0003xE-Fj; Thu, 14 Mar 2024 21:50:29 +0000 Received: by outflank-mailman (output) from mailman id 693500.1081633; Thu, 14 Mar 2024 21:50:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rksy5-0003x7-D3; Thu, 14 Mar 2024 21:50:29 +0000 Received: by outflank-mailman (input) for mailman id 693500; Thu, 14 Mar 2024 21:50:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rksy4-0003x1-Pp for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 21:50:28 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dd87e35d-e24c-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 22:50:26 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 55DA0614FE; Thu, 14 Mar 2024 21:50:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7750AC433F1; Thu, 14 Mar 2024 21:50:23 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: dd87e35d-e24c-11ee-a1ee-f123f15fe8a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710453024; bh=MgpMG91kr6ccIQgc4f7pyYqg/BDji6TRP7AqFlrewPI=; h=Date:From:To:cc:Subject:From; b=k/3bivuhbe+q35WO3YG+17un2vlI/2t4nXzluCmmyR2eLIELEsSkh3AX++ar5qheq y1xz5BlbMTfWf7fylPQFkJJoe6CkBR9Nu2ufBtDxumClghMao9/yvopB9AXBt/QmC2 KpN+bfeijWlo50Da4GsmZ2Ktho1F7u1zbMmcZrY4RkJJBigc5+WaNOKNGda6h04WfQ J6lY93RZyONZ7V1bx9bDBGZsAjblhCQSgEfoZ7ZBppSy/WYAwmmVWuEJpqLMoRCxVm f6BaSVDjlMyXlFWdQeM7rqJffLkorDW9heHbKLIb0zsB43j5vFpF05VLaDk+Mhy14/ IZoo73r+fVSRw== Date: Thu, 14 Mar 2024 14:50:21 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: xen-devel@lists.xenproject.org cc: sstabellini@kernel.org, andrew.cooper3@citrix.com, bertrand.marquis@arm.com, george.dunlap@citrix.com, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com Subject: [PATCH v2] docs/misra: add Rule 16.4 Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1710453050178100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefano Stabellini Acked-by: Bertrand Marquis --- Changes in v2: - mention -Werror - change the position of the in-code comment in the example - use "notifier pattern" in the example - clarify it is only an example --- docs/misra/rules.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 1e134ccebc..5c84091e45 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -478,6 +478,31 @@ maintainers if you want to suggest a change. - In addition to break, also other unconditional flow control stateme= nts such as continue, return, goto are allowed. =20 + * - `Rule 16.4 `_ + - Required + - Every switch statement shall have a default label + - Switch statements with enums as controlling expression don't need + a default label as gcc -Wall enables -Wswitch which warns (and + breaks the build as we use -Werror) if one of the enum labels is + missing from the switch. + + Switch statements with integer types as controlling expression + should have a default label: + + - if the switch is expected to handle all possible cases + explicitly, then a default label shall be added to handle + unexpected error conditions, using BUG(), ASSERT(), WARN(), + domain_crash(), or other appropriate methods; + + - if the switch is expected to handle a subset of all possible + cases, then an empty default label shall be added with an + in-code comment on top of the default label with a reason and + when possible a more detailed explanation. Example:: + + default: + /* Notifier pattern */ + break; + * - `Rule 16.2 `_ - Required - A switch label shall only be used when the most closely-enclosing --=20 2.25.1