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

Re: [PATCH] misra: add R14.4 R21.1 R21.2


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 24 Oct 2023 08:59:23 +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=pk+4keCSxUbtJQdAhBY3qwtGSvXiFLvAA5eg13nKJcY=; b=NSGZqP2FiLSctJ+/p+M7Z1ykgb+TTSg0Mo9nnuccKeXdPuWht7GqUnCObuYiuWN3LI+5LmWXDVt1Gu+0NYMe9fnVmKgjXyVjPGhdrL4tBuSdy9sNOFMZKBFS6J7pGP4wy7Z1ZNxZBpRVOffwr2J+GtOzPz525d/MmyDDJfaGEp4hrHJmxSXOA5LbXWI9iS3Kb9Ajz9bLAG2gkz5dDQ9WLoiCLj4RYrazr9LQHr7b+4EeqfsZBvVZhmny7Qi9iIo+B6iThopadN6jDoVEZnywANh7FU4bcYbokhID8ndmCqLzbZxFSm/iSZcK1D1xpsVWC39L3cUvXmzevEwmKv0dyg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oz+8dc426cXdWwa5EPJ1x/CCElGKzjvjU1WnqpieutY9zQUQ0dD8WPR/sHaF+vQ7RtTjkeJ2rN8+Nv4YAkLWjf9+w/k2uK4PTgjwW+if1iD8kTovoohLTJKJrJn+pgLiqTT4rhhVp6VBgYpwp5qnLUlYtLR5P4N7bmXjg4vGjPDcCEa526FYL0JI5lORJ0+WsABr0JIZ+Q4s1PlMO1bLaCbxLwWuCO+PzquoRsNrgQGlhzIO9OnrzmqcT1B9zJCSWpLIHEeoa9fAuR8HBbQhs6UwTPDOKtDSiZqw+DN3fdlcq8uisINwmKd+dp5xf5ik+4DBufw0e5S6V28EVxInFQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: julien@xxxxxxx, bertrand.marquis@xxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 24 Oct 2023 06:59:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.10.2023 01:31, Stefano Stabellini wrote:> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -422,6 +422,13 @@ maintainers if you want to suggest a change.
>  
>         while(0) and while(1) and alike are allowed.
>  
> +   * - `Rule 14.4 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_04.c>`_
> +     - Required
> +     - The controlling expression of an if statement and the controlling
> +       expression of an iteration-statement shall have essentially
> +       Boolean type
> +     - Implicit conversions to boolean are allowed

What, if anything, remains of this rule with this exception?

> @@ -479,6 +486,24 @@ maintainers if you want to suggest a change.
>         they are related
>       -
>  
> +   * - `Rule 21.1 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_01.c>`_
> +     - Required
> +     - #define and #undef shall not be used on a reserved identifier or
> +       reserved macro name
> +     - No identifiers should start with _BUILTIN to avoid clashes with

DYM "__builtin_"? Also gcc introduces far more than just __builtin_...()
into the name space.

> +       GCC reserved identifiers. In general, all identifiers starting with
> +       an underscore are reserved, and are best avoided.

This isn't precise enough. A leading underscore followed by a lower-case
letter or a number is okay to use for file-scope symbols. Imo we should
not aim at removing such uses, but rather encourage more use.

In this context, re-reading some of the C99 spec, I have to realize that
my commenting on underscore-prefixed macro parameters (but not underscore-
prefixed locals in macros) was based on ambiguous information in the spec.
I will try to remember to not comment on such anymore going forward.

> However, Xen
> +       makes extensive usage of leading underscores in header guards,
> +       bitwise manipulation functions, and a few other places. They are
> +       considered safe as checks have been done against the list of
> +       GCC's reserved identifiers. They don't need to be replaced.

This leaves quite vague what wants and what does not want replacing, nor
what might be okay to introduce subsequently despite violation this rule.

Jan



 


Rackspace

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