On 11/20/2014 11:56 AM, Taras Kondratiuk wrote:
On 11/19/2014 06:12 PM, Maxim Uvarov wrote:
Fix macro logic. Application has to be terminated in any case.

Signed-off-by: Maxim Uvarov <[email protected]>
---
  platform/linux-generic/include/api/odp_debug.h | 11 +++++++----
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h
index c9b2edd..1cbcb61 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -57,10 +57,13 @@ extern "C" {
  /**
   * Runtime assertion-macro - aborts if 'cond' is false.
   */
-#define ODP_ASSERT(cond, msg) \
-    do { if ((ODP_DEBUG == 1) && (!(cond))) { \
-        ODP_ERR("%s\n", msg); \
-        abort(); } \
+#define ODP_ASSERT(cond, msg)                \
+    do {                        \
+        if (!(cond)) {                \
+            if (ODP_DEBUG == 1)        \
+                ODP_ERR("%s\n", msg);    \
+            abort();            \
+        }                    \
      } while (0)

  /**


Current specification says that ODP_ASSERT can be disabled if not
needed. So it can be used in a fastpath to catch programming errors
and then disabled for release build.

If you want to have persistent asserts then let's make two macros:
- ODP_ASSERT() - persistent assert
- ODP_DEBUG_ASSERT() - assert enabled only in debug build.

BTW is this a part of public API? Will applications use it? I seems
not.
If it's in include/api/ header that it's public api. So that apps can use it. But we do not use it in odp.git. I agree that we need rename original to ODP_DEBUG_ASSERT(). And new version to ODP_ASSERT()
because ODP_ASSERT() was really confusing for me. Trap only in debug case.

Maxim.





_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to