[PATCH 1/4] assert.h: Add macros to assert status and use it
Ryan Long
thisisryanlong at gmail.com
Thu Feb 11 20:27:39 UTC 2021
These macros are to be used to check the status from calls that are flagged by
Coverity as 'Unchecked return value'.
---
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..7efaae4 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.
+ *
+ * Assert whether @a _status and @a _value are equal and ensure @a _status is
+ * marked as used when not building for debug.
+ *
+ * @param _status The return value to be checked.
+ * @param _value Indicates what @a _status is supposed to be.
+ */
+#define _Assert_Unused_return_value_equal(_status,_value) \
+ do { \
+ _Assert((_status) == (_value)); \
+ (void) (_status); \
+ } while (0)
+
+/**
+ * @brief Assert if unused return value is not equal.
+ *
+ * Assert whether @a _status and @a _value are not equal and ensure @a _status
+ * is marked as used when not building for debug.
+ *
+ * @param _status The return value to be checked.
+ * @param _value Indicates what @a _status is not supposed to be.
+ */
+#define _Assert_Unused_return_value_not_equal(_status,_value) \
+ do { \
+ _Assert((_status) != (_value)); \
+ (void) (_status); \
+ } while (0)
+
+/**
* @brief Returns true if thread dispatching is allowed.
*
* Thread dispatching can be repressed via _Thread_Disable_dispatch() or
--
1.8.3.1
More information about the devel
mailing list