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

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


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 13 Jun 2023 09:31:48 +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=T1pUrtbblts4fDfKa1wal2X24sd24GLC4UFvG/Zmklo=; b=kNOk6mmieeFKZvV/e4ad3xtDsCabwDssN2XDfQByh1rH3VYhYnAr1bEKpDpZz1ad7FV1Lub49gZNVNxZyhLn5hWH/A0DqJZweu5oFpeGVBrSf8//oi3O2t8zWgbUfEXLLxYP665UbaA3fOu0nt+mq3JQNVUM+5k9zK06Awix5An2WLQPyxd78/z2dGm9B6UPU04PAxwq2u6Z8RTkXZ7fRNAkzRvVg/NAhOjEb/UKhytDJX3mYqNokyvtWQqa5weAB355YSDF0hCivSaaVsjzMtICt/MR5hLP71x8uvbJeIyJHUIHtQw7aKlDvViSNC/ZABEQpHbdgqp3UBripUbugg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KB595KedDClevGbgX2bzwKX4H+c5GKNIrWlRlHifA/eGYs4HuZoUO/CZKjhKIVQY2OYQb1zPamMpRExalH4nGld9U0yvOb/wwuDgIQUf9OIWtdvaUrk8X1Sh8PsoDoNe/kvhh86+gNxRii/S9sklvnIvf7Q2S+0CaDq1J5CP2Jl8MK9CEhAOaJJdA77BXo74UGfbCaiXfngslxR6lcBNcs2f4aHs0MKZvmPSBew1WZZfWxGS5dVWIDK0iPR1sVwQIxRDHff775wq6Ve/cbZpMoUON+9d7goAMGHD+JnyzcISvFM/KMlOBa04DxT5w96vIFdraAS3VlF/30GLq3zNzA==
  • 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, roberto.bagnara@xxxxxxxxxxx, Stefano Stabellini <stefano.stabellini@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 13 Jun 2023 07:32:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.06.2023 05:44, Stefano Stabellini wrote:
> @@ -133,6 +146,13 @@ existing codebase are work-in-progress.
>         headers (xen/include/public/) are allowed to retain longer
>         identifiers for backward compatibility.
>  
> +   * - `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
> +     - In addition to the C99 types, we also consider appropriate types:
> +       unsigned char, unsigned short, unsigned long, unsigned long long,
> +       enum, and all explicitly signed integer types.

If I was to read this without the earlier discussion in mind, I would wonder
why the unsigned types are explicitly enumerated, but the signed ones are
described in more general terms. Can't it simply be "all explicitly unsigned
/ signed integer types", which then also covers e.g. uint32_t?

> @@ -143,6 +163,32 @@ 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
> +     - The rule asks that any integer literal that is implicitly
> +       unsigned is made explicitly unsigned by using one of the
> +       indicated suffixes.  As an example, on a machine where the int
> +       type is 32-bit wide, 0x77777777 is signed whereas 0x80000000 is
> +       (implicitly) unsigned. In order to comply with the rule, the
> +       latter should be rewritten as either 0x80000000u or 0x80000000U.
> +       Consistency considerations may suggest using the same suffix even
> +       when not required by the rule. For instance, if one has:
> +
> +       Original: f(0x77777777); f(0x80000000);
> +
> +       one might prefer
> +
> +       Solution 1: f(0x77777777U); f(0x80000000U);
> +
> +       over
> +
> +       Solution 2: f(0x77777777); f(0x80000000U);
> +
> +       after having ascertained that "Solution 1" is compatible with the
> +       intended semantics.

I think we should state here what we want people to do, not what "one
might prefer". That aspect aside, I'm not convinced the added text
(matching what Roberto did suggest) really addresses my concerns. Yet
I'm not going to pursue this any further - we'll see how this ends up
working in practice.

Jan



 


Rackspace

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