[PATCH v2 1/3] assert.h: Add macros to assert status and use it
Gedare Bloom
gedare at rtems.org
Fri Feb 12 16:14:15 UTC 2021
Hi Ryan,
On Fri, Feb 12, 2021 at 8:11 AM Ryan Long <thisisryanlong at gmail.com> wrote:
>
> These macros are to be used to check the status from calls that are flagged by
> Coverity as 'Unchecked return value'.
>
> Fix file assert.h
Thanks for these updates, it's almost there. Can you open a ticket
related to this feature improvement, and close that ticket from the
commit message?
> ---
> cpukit/include/rtems/score/assert.h | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/cpukit/include/rtems/score/assert.h b/cpukit/include/rtems/score/assert.h
> index cc32448..6bdb01e 100644
> --- a/cpukit/include/rtems/score/assert.h
> +++ b/cpukit/include/rtems/score/assert.h
> @@ -99,6 +99,36 @@ extern "C" {
> #endif
>
> /**
> + * @brief Assert if unused return value is equal.
Now that it is more generic, please replaced "return value" with "variable"
> + *
> + * Assert whether @a _var and @a _val are equal and ensure @a _var is
> + * marked as used when not building for debug.
> + *
> + * @param _var The return value to be checked.
ditto
> + * @param _val Indicates what @a _var is supposed to be.
> + */
> +#define _Assert_Unused_variable_equals(_var,_val) \
> + do { \
> + _Assert((_var) == (_val)); \
> + (void) (_var); \
> + } while (0)
> +
> +/**
> + * @brief Assert if unused return value is not equal.
ditto
> + *
> + * Assert whether @a _var and @a _val are not equal and ensure @a _var
> + * is marked as used when not building for debug.
> + *
> + * @param _var The return value to be checked.
ditto
> + * @param _val Indicates what @a _var is not supposed to be.
> + */
> +#define _Assert_Unused_variable_unequal(_var,_val) \
> + do { \
> + _Assert((_var) != (_val)); \
> + (void) (_var); \
> + } while (0)
> +
> +/**
> * @brief Returns true if thread dispatching is allowed.
> *
> * Thread dispatching can be repressed via _Thread_Disable_dispatch() or
> --
> 1.8.3.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list