From patchwork Fri Jun 10 21:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 12878116 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 08039C43334 for ; Fri, 10 Jun 2022 21:28:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.346747.572652 (Exim 4.92) (envelope-from ) id 1nzmAj-0008E8-Kj; Fri, 10 Jun 2022 21:28:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 346747.572652; Fri, 10 Jun 2022 21:28:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nzmAj-0008E1-HY; Fri, 10 Jun 2022 21:28:01 +0000 Received: by outflank-mailman (input) for mailman id 346747; Fri, 10 Jun 2022 21:28:00 +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 1nzmAi-0008Dv-CH for xen-devel@lists.xenproject.org; Fri, 10 Jun 2022 21:28:00 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 334508b0-e904-11ec-8901-93a377f238d6; Fri, 10 Jun 2022 23:27:59 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BDE50B83765; Fri, 10 Jun 2022 21:27:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD2D9C34114; Fri, 10 Jun 2022 21:27:56 +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: 334508b0-e904-11ec-8901-93a377f238d6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654896477; bh=KBP82+EJ08ywiXHELyDwBuHDDTpTUfvp7+EqgZWDwuE=; h=From:To:Cc:Subject:Date:From; b=V9pX9DwVjbvtYEz06hJ4GIQaq0IVH/unouwpz8f4YnuYJscUR510Wn5BndKvBABGB CDHDOLy8tSJ13msOeaxsIpK7X5d7cWK2z05MEqtzTg5xHVWq6qWOoiE7ZcGaLYc5Cp uZClXCJFWWiCYyT6tehZnf5cMSHYivtHYz8Bt56JDUJZHkrRVMx8a/HlbLH1yEV1XH wbCsYwNpLmM1RuTdohEe7ILyfPfZ8VjIxTN3HydDmY/4m1AibkCCd5JTuvpQncdVwV ETQIetSIXu0QA6pBoUAHsc7JwWGpcVRwG02+BVDTbtr7e8Pc8oLAxOonwYv6PtNwjr SZGdHdUO5F9Tw== From: Stefano Stabellini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, George.Dunlap@citrix.com, roger.pau@citrix.com, Artem_Mygaiev@epam.com, Andrew.Cooper3@citrix.com, julien@xen.org, Bertrand.Marquis@arm.com, jbeulich@suse.com, Stefano Stabellini , Bertrand Marquis , Julien Grall Subject: [PATCH v2] add more MISRA C rules to docs/misra/rules.rst Date: Fri, 10 Jun 2022 14:27:55 -0700 Message-Id: <20220610212755.1051640-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Add the new MISRA C rules agreed by the MISRA C working group to docs/misra/rules.rst. Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis Acked-by: Julien Grall Acked-by: Roger Pau Monné --- Given the minimal/trivial changes I kept the acked/reviewed-by. Changes in v2: - use max_t/min_t instead of MAX/MIN in the Rule 5.3 example - improve wording for the note of Rule 5.3 --- docs/misra/rules.rst | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 6ccff07765..c0bdc75987 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -89,6 +89,29 @@ existing codebase are work-in-progress. (xen/include/public/) are allowed to retain longer identifiers for backward compatibility. + * - `Rule 5.2 `_ + - Required + - Identifiers declared in the same scope and name space shall be + distinct + - The Xen characters limit for identifiers is 40. Public headers + (xen/include/public/) are allowed to retain longer identifiers + for backward compatibility. + + * - `Rule 5.3 `_ + - Required + - An identifier declared in an inner scope shall not hide an + identifier declared in an outer scope + - Using macros as macro parameters at invocation time is allowed + even if both macros use identically named local variables, e.g. + max_t(var0, min_t(var1, var2)) + + * - `Rule 5.4 `_ + - Required + - Macro identifiers shall be distinct + - The Xen characters limit for macro identifiers is 40. Public + headers (xen/include/public/) are allowed to retain longer + identifiers for backward compatibility. + * - `Rule 6.2 `_ - Required - Single-bit named bit fields shall not be of a signed type @@ -123,8 +146,75 @@ existing codebase are work-in-progress. declarations of objects and functions that have internal linkage - + * - `Rule 8.10 `_ + - Required + - An inline function shall be declared with the static storage class + - gnu_inline (without static) is allowed. + * - `Rule 8.12 `_ - Required - Within an enumerator list the value of an implicitly-specified enumeration constant shall be unique - + + * - `Rule 9.1 `_ + - Mandatory + - The value of an object with automatic storage duration shall not + be read before it has been set + - Rule clarification: do not use variables before they are + initialized. An explicit initializer is not necessarily required. + Try reducing the scope of the variable. If an explicit + initializer is added, consider initializing the variable to a + poison value. + + * - `Rule 9.2 `_ + - Required + - The initializer for an aggregate or union shall be enclosed in + braces + - + + * - `Rule 13.6 `_ + - Mandatory + - The operand of the sizeof operator shall not contain any + expression which has potential side effects + - + + * - `Rule 14.1 `_ + - Required + - A loop counter shall not have essentially floating type + - + + * - `Rule 16.7 `_ + - Required + - A switch-expression shall not have essentially Boolean type + - + + * - `Rule 17.3 `_ + - Mandatory + - A function shall not be declared implicitly + - + + * - `Rule 17.4 `_ + - Mandatory + - All exit paths from a function with non-void return type shall + have an explicit return statement with an expression + - + + * - `Rule 20.7 `_ + - Required + - Expressions resulting from the expansion of macro parameters + shall be enclosed in parentheses + - + + * - `Rule 20.13 `_ + - Required + - A line whose first token is # shall be a valid preprocessing + directive + - + + * - `Rule 20.14 `_ + - Required + - All #else #elif and #endif preprocessor directives shall reside + in the same file as the #if #ifdef or #ifndef directive to which + they are related + -