From patchwork Wed Mar 13 00:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13590787 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 65374C54E5D for ; Wed, 13 Mar 2024 00:28:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.692231.1079147 (Exim 4.92) (envelope-from ) id 1rkCU4-0005Si-Oj; Wed, 13 Mar 2024 00:28:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 692231.1079147; Wed, 13 Mar 2024 00:28:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rkCU4-0005Sb-M5; Wed, 13 Mar 2024 00:28:40 +0000 Received: by outflank-mailman (input) for mailman id 692231; Wed, 13 Mar 2024 00:28:39 +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 1rkCU2-0005SV-Qj for xen-devel@lists.xenproject.org; Wed, 13 Mar 2024 00:28:39 +0000 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a0584eec-e0d0-11ee-a1ee-f123f15fe8a2; Wed, 13 Mar 2024 01:28:36 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E422CCE172D; Wed, 13 Mar 2024 00:28:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A4C1C433C7; Wed, 13 Mar 2024 00:28:29 +0000 (UTC) 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: a0584eec-e0d0-11ee-a1ee-f123f15fe8a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710289710; bh=VETAQc7mohf8kIx42D/f98f55cEIgZLe8uhKx+/HHMk=; h=Date:From:To:cc:Subject:From; b=B0S1cAJdjnFAxW73IAjHgtdAiSeXAC8PHzmDsXfh1Nbi5/OF8kFsUrqsYg5PLQwF5 1rA7jL57OMStyzXvVeDPa5lrYe1iUH+NGtpOocXtHfgWhx9fI8fvPnD5K+KDshl6Go FF1Go2kIS+kc9aWGpCzqHAcsrTxfBLCl4jjSEnfeTOHXig3dgqBL+9VpEHRWarJr+T JWCBrd88Ao4le+c9/n6/LSKApmgk+7pvzXHE/tdpmOFpk4HPHHKnxIh9+kgPfWAMot AjYUTQrNIEQdBPgtnMyT6D+RFwDsQMBGCvAQbsADstNs8VGSrFZ0nMf/58KFyx8Wfn /xyEpOhOlMmvg== Date: Tue, 12 Mar 2024 17:28:27 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: xen-devel@lists.xenproject.org cc: andrew.cooper3@citrix.com, bertrand.marquis@arm.com, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org Subject: [PATCH] docs/misra: add Rule 16.4 Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Signed-off-by: Stefano Stabellini --- I tested the rendered output and it is correct both on the gitlab UI as well as with tools like rst2html. --- docs/misra/rules.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 1e134ccebc..5e9367f11c 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -478,6 +478,30 @@ maintainers if you want to suggest a change. - In addition to break, also other unconditional flow control statements such as continue, return, goto are allowed. + * - `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) 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 a default label shall be added with an + in-code comment as follows:: + + /* only handle a subset of the possible cases */ + default: + break; + * - `Rule 16.2 `_ - Required - A switch label shall only be used when the most closely-enclosing