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

Re: [PATCH] Improved reStructuredText formatting of Misra C Rules


  • To: Bernhard Kaindl <bernhard.kaindl@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 4 May 2026 07:27:31 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 04 May 2026 05:27:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 29.04.2026 09:22, Bernhard Kaindl wrote:
> Code blocks in the RFC rules can be converted as C syntax-highlighted
> pretty pieces of code using `.. code:: C` inline elements:
> https://docutils.sourceforge.io/docs/ref/rst/directives.html#code
> 
> For reference, the current formatting used are 'Indented Literal Blocks':
> https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#toc-entry-23
> 
> In this example, docs/misra/rules.rst, line 128 starts an Indented
> Literal Block by ending the paragraph with "violations::"
> (note the :: at then end of the paragraph which is enables it):
> 
>          - Functions that are no-return due to calls to the 
> `ASSERT_UNREACHABLE()`
>            macro in debug build configurations are not considered violations::
> 
>               static inline bool
>               arch_vcpu_ioreq_completion(enum vio_completion completion)
>               {
>                   ASSERT_UNREACHABLE();
>                   return false;
>               }
> 
> Format such code blocks as C code blocks and apply ``function()`` around
> functions to make them inline linterals for monospace formatting.

Nit: literal

> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -115,20 +115,29 @@ maintainers if you want to suggest a change.
>       - Required
>       - A project shall not contain unreachable code
>       - The following are allowed:
> -         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) 
> { S; }
> +         - Invariantly constant conditions, e.g.
> +
> +           .. code:: C
> +
> +              if ( IS_ENABLED(CONFIG_HVM) ) {
> +                S;
> +              }

If already you reformat like this, then please fully to proper Xen style.

>           - Switch with a controlling value statically determined not to
>             match one or more case statements
>           - Functions that are intended to be referenced only from
> -           assembly code (e.g. 'do_trap_fiq')
> -         - asm-offsets.c, as they are not linked deliberately, because
> +           assembly code (e.g. ``do_trap_fiq``)
> +         - ``asm-offsets.c``, as they are not linked deliberately, because

This is a file name, not code?

>             they are used to generate definitions for asm modules
>           - Declarations without initializer are safe, as they are not
>             executed
> -         - Functions that are no-return due to calls to the 
> `ASSERT_UNREACHABLE()`
> -           macro in debug build configurations are not considered 
> violations::
> +         - Functions that are no-return due to calls to the 
> ``ASSERT_UNREACHABLE()``
> +           macro in debug build configurations are not considered violations:
> +
> +           .. code:: C
>  
>                static inline bool
> -              arch_vcpu_ioreq_completion(enum vio_completion completion)
> +              arch_vcpu_ioreq_completion(int c)

I don't agree with making a change making an example not match actual code.
If you truly want to abstract this (to shorten the line) then please also
change the function name.

> @@ -207,16 +216,20 @@ maintainers if you want to suggest a change.
>  
>         Clashes between bitops functions and macro names are allowed
>         because they are used for input validation and error handling.
> -       Example::
> +       Example:
>  
> -           static inline void set_bit(int nr, volatile void *addr)
> +       .. code:: C
> +
> +           static inline void set_bit(int nr, volatile void *a)
>             {
> -               asm volatile ( "lock btsl %1,%0"
> -                              : "+m" (ADDR) : "Ir" (nr) : "memory");
> +               asm volatile ( "lock btsl %1,%0 "

Why the new trailing blank in the string literal?

> +                              : "+m" (a)
> +                              : "Ir" (nr) : "memory");

Where you want to add a blank while re-flowing is before the parenthesis
here.

>             }
> -           #define set_bit(nr, addr) ({                            \
> -               if ( bitop_bad_size(addr) ) __bitop_bad_size();     \
> -               set_bit(nr, addr);                                  \
> +
> +           #define set_bit(nr, addr) ({                       \
> +               if ( bitop_bad_size(addr) ) __bitop_bad_size();\

There wants to be a blank before the semicolon. To better shorten line
length:

               if ( bitop_bad_size(addr) ) \
                   __bitop_bad_size();     \

Jan



 


Rackspace

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