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

Re: [PATCH] docs/misra: add rules 10.1 10.2 10.3 10.4


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 25 Aug 2023 15:40:04 +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=XCvwl3+TYsgomQ7wnBMhIBqRSDn30ax0l9gVfd4YzMk=; b=c29c/jpIUyt8/R017jbENjFvHvl74eec9TS0QO/bp0pipqzIQOXCfM3MRPq2o5ILbS5VtISV2Gw0lVkDhBWtkdH76wrGTRRFIDhef7v69QkCjgyoKNoetRQNBDEZpQD8AN/BxTqdIzHBYx4LgJMkhdskrv1pVx/++9fR1+mUziraP+ocKF1ZYCdCiQpTqg9rY3CCjk7yaGoxmRuvEGemrHFNbrqMP2g/XFeSVrcUzuRYymRwHDz075xBfBnq0XjEORlcbt0VumyXVS2DrYqOP3hZoqls4bsokL+JQBgoqhwNVM4NbK2faydzfq3utKYJXQQUuSmKZRgMA7m0NxTpAw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXj/D1FW9LCIs0SUaLsnqC/BmKocRnVFiXYmb6MWRAArWvcT/xozhdL6Dulrof3FwiKgSWGpQPj8FTPhx7h/UxUpsbs83mMp8anfVwIp6PEZhCUFkbb0wXMBWCu7RmsNhNrVF5dIZ88zaoW0m1S0goCMAGkq2dh9Z/H+OFuQtAonKe5T0BRRRD2Vz69dc4bZQrWWoGAiEAkkACepVonpXL9JMrB24H+JG0LwhtaJsfU8VLo0b/QaNa42DSSvC+4g+sZu2VBhSCadsQcdJiepv2bmjRmJINSufJAtxAfe8ObYhCxI3HoBkclHefrleiOR8oUzcC8nlMlmzNvb1KOtNw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, julien@xxxxxxx, george.dunlap@xxxxxxxxxx, bertrand.marquis@xxxxxxx, nicola.vetrini@xxxxxxxxxxx, roberto.bagnara@xxxxxxxxxxx, Stefano Stabellini <stefano.stabellini@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 25 Aug 2023 13:40:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.08.2023 01:14, Stefano Stabellini wrote:
> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -318,6 +318,58 @@ maintainers if you want to suggest a change.
>       - An element of an object shall not be initialized more than once
>       -
>  
> +   * - `Rule 10.1 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_01.c>`_
> +     - Required
> +     - Operands shall not be of an inappropriate essential type
> +     - The following are allowed:
> +         - Value-preserving conversions of integer constants
> +         - Bitwise and, or, xor, one's complement, bitwise and assignment,
> +           bitwise or assignment, bitwise xor assignment (bitwise and, or, 
> xor
> +           are safe on non-negative integers; also Xen assumes two's 
> complement
> +           representation)
> +         - Left shift, right shift, left shift assignment, right shift
> +           assignment (see C-language-toolchain.rst for assumptions on
> +           compilers' extensions)

Is "assumptions" the right term here? We don't just assume these are there,
we actually checked their doc and behavior. Maybe simply "uses of" instead?

> +         - Implicit conversions to boolean for logical operators' arguments

What is "logical operators" here? Perhaps this wants to be "conditionals"
instead, to cover all of ?:, if(), while(), for() (did I forget any?), of
which only the first is an operator?

> +   * - `Rule 10.3 
> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_03.c>`_
> +     - Required
> +     - The value of an expression shall not be assigned to an object
> +       with a narrower essential type or of a dierent essential type

Nit: ff missing?

> +       category
> +     - Please beware that this rule has many violations in the Xen
> +       codebase today, and its adoption is aspirational. However, when
> +       submitting new patches please try to decrease the number of
> +       violations when possible.
> +
> +       gcc has a helpful warning that can help you spot and remove
> +       violations of this kind: conversion. For instance, you can use
> +       it as follows:
> +
> +       cd xen; CFLAGS="-Wconversion -Wno-error=sign-conversion 
> -Wno-error=conversion" make

Maybe slightly shorter as

CFLAGS="-Wconversion -Wno-error=sign-conversion -Wno-error=conversion" make -C 
xen

?

Jan



 


Rackspace

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