[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] docs/misra: new rules addition


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, roberto.bagnara@xxxxxxxxxxx
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 7 Jun 2023 10:32:46 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sWVl1QsY/cVcT3X9J19Z5ho+B2U7bWpJkaXyPw8HXxk=; b=e+zY1BCV0/ZMs3HOAJ89KJd8/ugHqfnNkMLcYf3a3+U/1InTpS7BTz4NfwQWAgKLsjptaLtMo6u00tlCyY75HOpDV8EqQKLyEFEksAbF8hg2UmW2gROeZ01kMtvdy2/FwdGHVU7WIppJaC1MvvnE30n6fAseq9HnqhSEq9AFFie6IPbiAW97lQ78F9e+JWSUufavjIYWh9BPzTzgxrxlW03VcQy6apMeGse0WB33LH/jsZRnxZXGQtqitMRXLCy03Ra6VCZ0cCTEB1In6jvM1JUTeDq3srnmKyHL0/NOCKDFSwi1fosBAnlUwgZu7J7Ucq0QqOtLEzpmidMR//xP6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qi0uvay6jNOeNFO95Qtqx0qGcxNH+oBqHv3VX7t9Vl9+fOK8fhzLIYyQxJfnSHTztBt2nKpgdPWbMhJcXsqQlYwgF2SUSm6R9RlQmuYsBcuCJDeNh/EDB+zLZwg49VBHb8+WnI3ldKnD6X6mTfDT1RiajyXbdC32W0Z5KqU1WrxR6I2gngFoSLbWq5Igpb+nJfw6MEgCwnPFuBQV2fZGg+mUDfQjek1kAaxJ044stl+hbyKnWRD3So5//Kuc8ICDVoUwX9YEzuusyjFWUgOQGEgiR3GfmnuAaTzdbbnY3dGRNCVW0kB2RducRhQxQwxMeOYz+UZ7C+K1bnAQVIn5Kg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: julien@xxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, bertrand.marquis@xxxxxxx, Stefano Stabellini <stefano.stabellini@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 07 Jun 2023 08:33:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.06.2023 03:38, Stefano Stabellini wrote:
> From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
> 
> For Dir 1.1, a document describing all implementation-defined behaviour
> (i.e. gcc-specific behavior) will be added to docs/misra, also including
> implementation-specific (gcc-specific) appropriate types for bit-field
> relevant to Rule 6.1.
> 
> Rule 21.21 is lacking an example on gitlab but the rule is
> straightforward: we don't use stdlib at all in Xen.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
> ---
> We also discussed Rules 2.1, 5.5 and 7.4 but they require more work
> before we can decide one way or the other.

Since I wasn't able to attend yesterday's meeting, please forgive a
couple of remarks:

> @@ -133,6 +146,16 @@ existing codebase are work-in-progress.
>         headers (xen/include/public/) are allowed to retain longer
>         identifiers for backward compatibility.
>  
> +   * - `Rule 5.6 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_
> +     - Required
> +     - A typedef name shall be a unique identifier
> +     -

Considering that the rule requires uniqueness across the entire code
base (and hence precludes e.g. two functions having identically named
local typedefs), I'm a little puzzled this was adopted. I for one
question that a use like the one mentioned is really at risk of being
confusing. Instead I think that the need to change at least one of
the names is at risk of making the code less readable then, even if
ever so slightly. (All of this said - I don't know if we have any
violations of this rule.)

> +   * - `Rule 6.1 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_06_01.c>`_
> +     - Required
> +     - Bit-fields shall only be declared with an appropriate type
> +     -

This requires you have settled on what "an appropriate type" is, i.e.
whether our uses of e.g. types wider than int is meant to become a
deviation, or will need eliminating. I suppose the outcome of this
could do with mentioning as a remark here.

> @@ -143,6 +166,12 @@ existing codebase are work-in-progress.
>       - Octal constants shall not be used
>       -
>  
> +   * - `Rule 7.2 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_02.c>`_
> +     - Required
> +     - A "u" or "U" suffix shall be applied to all integer constants
> +       that are represented in an unsigned type
> +     -

"Represented in an unsigned type" means there is a dependency on the
target architecture and compiler capabilities: Representation can only
be determined once knowing the underlying binary ABI, and uses in #if
and alike require knowing the widest integer type's size that the
compiler supports. As a consequence this looks like it may require, in
certain cases, to add u/U conditionally. Any such conditionals pose a
risk of cluttering the code.

> @@ -314,6 +343,11 @@ existing codebase are work-in-progress.
>         used following a subsequent call to the same function
>       -
>  
> +   * - Rule 21.21
> +     - Required
> +     - The Standard Library function system of <stdlib.h> shall not be used
> +     -

I wish inapplicable (to us) rules would also be marked as such.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.