Xen-Devel Archive mirror
 help / color / mirror / Atom feed
* [PATCH] docs/misra: add D4.12
@ 2024-05-14 23:15 Stefano Stabellini
  2024-05-15  7:35 ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2024-05-14 23:15 UTC (permalink / raw
  To: xen-devel
  Cc: sstabellini, Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Bertrand Marquis, Julien Grall, Michal Orzel, roberto.bagnara,
	consulting

Add D4.12 with the same explanation as the rules of the R21 series.
D4.12 refers to the standard library memory allocation functions and
similar third party libraries with memory allocation functions. It
doesn't refer to the in-tree implementation we have in Xen which is
subject to MISRA C rules and MISRA C scanning.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index 80e5e972ad..bc8506add4 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -76,6 +76,11 @@ maintainers if you want to suggest a change.
        considered libraries from MISRA C point of view as they are
        imported in source form)
 
+   * - `Dir 4.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_12.c>`_
+     - Required
+     - Dynamic memory allocation shall not be used
+     - Xen doesn't provide, use, or link against a Standard Library [#xen-stdlib]_
+
    * - `Dir 4.14 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_14.c>`_
      - Required
      - The validity of values received from external sources shall be


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] docs/misra: add D4.12
  2024-05-14 23:15 [PATCH] docs/misra: add D4.12 Stefano Stabellini
@ 2024-05-15  7:35 ` Jan Beulich
  2024-05-15 22:18   ` Stefano Stabellini
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2024-05-15  7:35 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: Andrew Cooper, Roger Pau Monné, Bertrand Marquis,
	Julien Grall, Michal Orzel, roberto.bagnara, consulting,
	xen-devel

On 15.05.2024 01:15, Stefano Stabellini wrote:
> Add D4.12 with the same explanation as the rules of the R21 series.
> D4.12 refers to the standard library memory allocation functions and
> similar third party libraries with memory allocation functions. It
> doesn't refer to the in-tree implementation we have in Xen which is
> subject to MISRA C rules and MISRA C scanning.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> 
> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> index 80e5e972ad..bc8506add4 100644
> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -76,6 +76,11 @@ maintainers if you want to suggest a change.
>         considered libraries from MISRA C point of view as they are
>         imported in source form)
>  
> +   * - `Dir 4.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_12.c>`_
> +     - Required
> +     - Dynamic memory allocation shall not be used
> +     - Xen doesn't provide, use, or link against a Standard Library [#xen-stdlib]_

I'm having trouble connecting this remark with the directive. We do have
dynamic memory allocation routines, and we use them. It doesn't really
matter that they don't come from an external library, does it?

Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] docs/misra: add D4.12
  2024-05-15  7:35 ` Jan Beulich
@ 2024-05-15 22:18   ` Stefano Stabellini
  2024-05-27 18:22     ` Stefano Stabellini
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2024-05-15 22:18 UTC (permalink / raw
  To: Jan Beulich
  Cc: Stefano Stabellini, Andrew Cooper, Roger Pau Monné,
	Bertrand Marquis, Julien Grall, Michal Orzel, roberto.bagnara,
	consulting, xen-devel

On Wed, 15 May 2024, Jan Beulich wrote:
> On 15.05.2024 01:15, Stefano Stabellini wrote:
> > Add D4.12 with the same explanation as the rules of the R21 series.
> > D4.12 refers to the standard library memory allocation functions and
> > similar third party libraries with memory allocation functions. It
> > doesn't refer to the in-tree implementation we have in Xen which is
> > subject to MISRA C rules and MISRA C scanning.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> > 
> > diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> > index 80e5e972ad..bc8506add4 100644
> > --- a/docs/misra/rules.rst
> > +++ b/docs/misra/rules.rst
> > @@ -76,6 +76,11 @@ maintainers if you want to suggest a change.
> >         considered libraries from MISRA C point of view as they are
> >         imported in source form)
> >  
> > +   * - `Dir 4.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_12.c>`_
> > +     - Required
> > +     - Dynamic memory allocation shall not be used
> > +     - Xen doesn't provide, use, or link against a Standard Library [#xen-stdlib]_
> 
> I'm having trouble connecting this remark with the directive. We do have
> dynamic memory allocation routines, and we use them. It doesn't really
> matter that they don't come from an external library, does it?

Similarly to the 21.x rules series, it makes a difference if they are
external libraries or code within the project. The rule points out that
the standard library memory allocation functions can lead to undefined
behavior. On the other hand, our own implementation under xen.git is
subject to MISRA C scanning and all the other MISRA C rules.

The example in the link above, shows a use-after-free error that in our
case it should be caught by other MISRA C rules scanning.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] docs/misra: add D4.12
  2024-05-15 22:18   ` Stefano Stabellini
@ 2024-05-27 18:22     ` Stefano Stabellini
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2024-05-27 18:22 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Bertrand Marquis, Julien Grall, Michal Orzel, roberto.bagnara,
	consulting, xen-devel

On Wed, 15 May 2024, Stefano Stabellini wrote:
> On Wed, 15 May 2024, Jan Beulich wrote:
> > On 15.05.2024 01:15, Stefano Stabellini wrote:
> > > Add D4.12 with the same explanation as the rules of the R21 series.
> > > D4.12 refers to the standard library memory allocation functions and
> > > similar third party libraries with memory allocation functions. It
> > > doesn't refer to the in-tree implementation we have in Xen which is
> > > subject to MISRA C rules and MISRA C scanning.
> > > 
> > > Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> > > 
> > > diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> > > index 80e5e972ad..bc8506add4 100644
> > > --- a/docs/misra/rules.rst
> > > +++ b/docs/misra/rules.rst
> > > @@ -76,6 +76,11 @@ maintainers if you want to suggest a change.
> > >         considered libraries from MISRA C point of view as they are
> > >         imported in source form)
> > >  
> > > +   * - `Dir 4.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_12.c>`_
> > > +     - Required
> > > +     - Dynamic memory allocation shall not be used
> > > +     - Xen doesn't provide, use, or link against a Standard Library [#xen-stdlib]_
> > 
> > I'm having trouble connecting this remark with the directive. We do have
> > dynamic memory allocation routines, and we use them. It doesn't really
> > matter that they don't come from an external library, does it?
> 
> Similarly to the 21.x rules series, it makes a difference if they are
> external libraries or code within the project. The rule points out that
> the standard library memory allocation functions can lead to undefined
> behavior. On the other hand, our own implementation under xen.git is
> subject to MISRA C scanning and all the other MISRA C rules.
> 
> The example in the link above, shows a use-after-free error that in our
> case it should be caught by other MISRA C rules scanning.

Just to close the loop on this -- I spoke with Roberto about D4.12, and
we decided that it is best to leave out this directive for now.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-27 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14 23:15 [PATCH] docs/misra: add D4.12 Stefano Stabellini
2024-05-15  7:35 ` Jan Beulich
2024-05-15 22:18   ` Stefano Stabellini
2024-05-27 18:22     ` Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).