mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
include/assert.h: Wrap definitions of assertion macros in do while. Suggested by orbitalfox
This commit is contained in:
+33
-5
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/assert.h
|
* include/assert.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -58,10 +58,24 @@
|
|||||||
#ifdef CONFIG_HAVE_FILENAME
|
#ifdef CONFIG_HAVE_FILENAME
|
||||||
|
|
||||||
# define ASSERT(f) \
|
# define ASSERT(f) \
|
||||||
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
do \
|
||||||
|
{ \
|
||||||
|
if (!(f)) \
|
||||||
|
{ \
|
||||||
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
# define VERIFY(f) \
|
# define VERIFY(f) \
|
||||||
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
do \
|
||||||
|
{ \
|
||||||
|
if ((f) < 0) \
|
||||||
|
{ \
|
||||||
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
# define PANIC() \
|
# define PANIC() \
|
||||||
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
|
||||||
@@ -69,10 +83,24 @@
|
|||||||
# ifdef CONFIG_DEBUG
|
# ifdef CONFIG_DEBUG
|
||||||
|
|
||||||
# define DEBUGASSERT(f) \
|
# define DEBUGASSERT(f) \
|
||||||
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
do \
|
||||||
|
{ \
|
||||||
|
if (!(f)) \
|
||||||
|
{ \
|
||||||
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
# define DEBUGVERIFY(f) \
|
# define DEBUGVERIFY(f) \
|
||||||
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
do \
|
||||||
|
{ \
|
||||||
|
if ((f) < 0) \
|
||||||
|
{ \
|
||||||
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
# define DEBUGPANIC() \
|
# define DEBUGPANIC() \
|
||||||
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
|
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
|
||||||
|
|||||||
Reference in New Issue
Block a user