[PATCH v2] score: Define _Assert() for static analysis runs

Gedare Bloom gedare at rtems.org
Mon Feb 1 15:52:48 UTC 2021


Thanks, I like that.

On Sun, Jan 31, 2021 at 11:07 PM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> The goal is to reduce false positive NULL_RETURNS,
> PW.NORETURN_FUNCTION_DOES_RETURN, PW.SET_BUT_NOT_USED,
> UNUSED_VALUE, etc. issues produced by Coverity.
>
> Define RTEMS_STATIC_ANALYSIS if a static analysis run by Coverity is
> performed.
> ---
>  cpukit/include/rtems/score/assert.h   |  4 ++--
>  cpukit/include/rtems/score/basedefs.h | 11 +++++++++++
>  2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/assert.h
> b/cpukit/include/rtems/score/assert.h
> index 2bf1703f19..cc3244844c 100644
> --- a/cpukit/include/rtems/score/assert.h
> +++ b/cpukit/include/rtems/score/assert.h
> @@ -46,9 +46,9 @@ extern "C" {
>
>  /**
>   * @brief Assertion similar to assert() controlled via RTEMS_DEBUG
> instead of
> - * NDEBUG.
> + *   NDEBUG and static analysis runs.
>   */
> -#if defined( RTEMS_DEBUG )
> +#if defined( RTEMS_DEBUG ) || defined( RTEMS_STATIC_ANALYSIS )
>
>    /**
>     * @brief Macro with method name used in assert output
> diff --git a/cpukit/include/rtems/score/basedefs.h
> b/cpukit/include/rtems/score/basedefs.h
> index a98b80f0dd..fe5f4ab7c7 100644
> --- a/cpukit/include/rtems/score/basedefs.h
> +++ b/cpukit/include/rtems/score/basedefs.h
> @@ -748,6 +748,17 @@ extern "C" {
>    #define RTEMS_SECTION( _section )
>  #endif
>
> +/* Generated from spec:/rtems/basedefs/if/static-analysis */
> +
> +/**
> + * @ingroup RTEMSAPIBaseDefs
> + *
> + * @brief It is defined if a static analysis run is performed.
> + */
> +#if defined(__COVERITY__)
> +  #define RTEMS_STATIC_ANALYSIS
> +#endif
> +
>  /* Generated from spec:/rtems/basedefs/if/static-assert */
>
>  /**
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210201/5bfcc9a1/attachment.html>


More information about the devel mailing list