From nobody Sun May 19 11:06:56 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=1654822172; cv=none; d=zohomail.com; s=zohoarc; b=KHs+zRX5qFhXlmG22CUKH1gCVmziEhfvT9BS66F3/hbhnPv4lNSSqSCu5kguoINIZNTsiborkDTO03DojmuBO+shFW5deOp5apvzey8DNUDXRLHqjrdYYYRiI1EVTimuBjpYurNh3vcGVKeMPBPv8LksYplgc7Cnx+TjhJg31po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654822172; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=13tLQYsa/d1tnJx/UXPX9Avg4OtTK9DgFPDRjx3Gl2Y=; b=JJGvJ0pdY3yZBZSw0mLGvXWbCegPhvKp2+W433yfwXYPTbHB0ixRnYkMYHQCebgokc/MH+RhUgNDOr+fOPU3BB4lCmfB2pFO4GAxCszA9X//LYi1eEeZxCRGxVziePy10JhnQKuFBEzYLIZLbeahQqTat5BdOrSJ0Ct/AebnZCQ= 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 16548221721321018.5885820691215; Thu, 9 Jun 2022 17:49:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.345697.571368 (Exim 4.92) (envelope-from ) id 1nzSpP-00013V-4z; Fri, 10 Jun 2022 00:48:43 +0000 Received: by outflank-mailman (output) from mailman id 345697.571368; Fri, 10 Jun 2022 00:48:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nzSpP-00013O-2F; Fri, 10 Jun 2022 00:48:43 +0000 Received: by outflank-mailman (input) for mailman id 345697; Fri, 10 Jun 2022 00:48:41 +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 1nzSpN-00013I-6D for xen-devel@lists.xenproject.org; Fri, 10 Jun 2022 00:48:41 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0f61a36d-e857-11ec-bd2c-47488cf2e6aa; Fri, 10 Jun 2022 02:48:38 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 68757615D1; Fri, 10 Jun 2022 00:48:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56752C34114; Fri, 10 Jun 2022 00:48:34 +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: 0f61a36d-e857-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654822114; bh=IDgNoo+BA5lAS7UKqsa5Qr/m/XsUGO4spdDI9oW0io0=; h=Date:From:To:cc:Subject:From; b=r+GfQOEe+TGzWbFJfMwnH4fYrjWZZQRVhyAva4Y+/OiPh1E4SSqDeTjpnIW7pvvxX bXur0ZnDs3qZwwQGg+dGctG9VrseaxY30kzkBnNZeVEpg15sAa6Gu5gC4D+TRLbw2i iI3VhQhQjnCO05mLKRy3eKg6EmkAYLO8zmWxq5ovRCyXS9RKoHxpw+TT8Vw2OhoZ3D LdcGN4mP+4T8p+xp5eoCDbclHmmHcX7rkM/szvd25BrG0J+XnMNLcEhIJ48Xnakrlh K01o6bsYJ3pSeyRHlloTrTzpvXJtTnJyytS1kTVYY7jGWZeMsR9Xe6hohQsxNZ4MEm W1Qxd6zjGpadw== Date: Thu, 9 Jun 2022 17:48:26 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: xen-devel@lists.xenproject.org cc: sstabellini@kernel.org, jbeulich@suse.com, George.Dunlap@citrix.com, roger.pau@citrix.com, Artem_Mygaiev@epam.com, Andrew.Cooper3@citrix.com, julien@xen.org, Bertrand.Marquis@arm.com Subject: [PATCH] add more MISRA C rules to docs/misra/rules.rst 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: 1654822173211100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the new MISRA C rules agreed by the MISRA C working group to docs/misra/rules.rst. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall Acked-by: Roger Pau Monn=C3=A9 Reviewed-by: Bertrand Marquis --- I added the rules that we agreed upon this morning together with all the notes we discussed, in particular: - macros as macro parameters at invocation time for Rule 5.3 - the clarification of Rule 9.1 - gnu_inline exception for Rule 8.10 diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 6ccff07765..5c28836bc8 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -89,6 +89,28 @@ existing codebase are work-in-progress. (xen/include/public/) are allowed to retain longer identifiers for backward compatibility. =20 + * - `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, + e.g. MAX(var0, MIN(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 +145,75 @@ existing codebase are work-in-progress. declarations of objects and functions that have internal linkage - =20 + * - `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 + -