1
0
Fork 0
forked from nuttx/nuttx-update

arch: up_assert shouldn't call exit directly

since exit will be only callable from userspace and change
the 1st argument from "const uint8_t *" to "const char *"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I86487d57210ab63109148232da71dbc4d60a563b
This commit is contained in:
Xiang Xiao 2020-06-07 14:51:54 +08:00 committed by Abdelatif Guettouche
parent 774ea6eae7
commit d6827cab60
29 changed files with 152 additions and 140 deletions

View file

@ -2147,7 +2147,7 @@ The specific environmental definitions are unique for each board but should incl
<h3><a name="upassert">4.2.13 <code>up_assert()</code></a></h3> <h3><a name="upassert">4.2.13 <code>up_assert()</code></a></h3>
<p><b>Function Prototype</b>:<br> <p><b>Function Prototype</b>:<br>
<code>void up_assert(FAR const uint8_t *filename, int linenum);</code> <code>void up_assert(FAR const char *filename, int linenum);</code>
</p> </p>
<p><b>Description</b>. <p><b>Description</b>.

View file

@ -283,8 +283,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -313,7 +312,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -325,7 +323,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -355,5 +353,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -340,8 +340,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -370,7 +369,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -382,7 +380,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -412,5 +410,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -353,8 +353,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -394,7 +393,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -406,7 +404,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -446,5 +444,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -347,8 +347,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -383,7 +382,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -395,7 +393,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -435,5 +433,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -333,8 +333,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -363,7 +362,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -375,7 +373,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -405,5 +403,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -347,8 +347,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -383,7 +382,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -395,7 +393,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -435,5 +433,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(arm_getsp(), running_task(), filename, lineno); board_crashdump(arm_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -79,8 +79,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -109,7 +108,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -145,7 +143,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -181,5 +179,5 @@ void up_assert(const uint8_t *filename, int lineno)
usbtrace_enumerate(assert_tracecallback, NULL); usbtrace_enumerate(assert_tracecallback, NULL);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -285,8 +285,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -315,7 +314,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -327,7 +325,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -357,5 +355,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(hc_getsp(), running_task(), filename, lineno); board_crashdump(hc_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -78,8 +78,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -108,7 +107,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -144,7 +142,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -180,5 +178,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(mips_getsp(), running_task(), filename, lineno); board_crashdump(mips_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -78,8 +78,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -113,7 +112,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -149,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -185,5 +183,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(misoc_getsp(), running_task(), filename, lineno); board_crashdump(misoc_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -78,8 +78,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -113,7 +112,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -149,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t * filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -184,5 +182,5 @@ void up_assert(const uint8_t * filename, int lineno)
board_crashdump(misoc_getsp(), running_task(), filename, lineno); board_crashdump(misoc_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -340,8 +340,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -370,7 +369,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -382,7 +380,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -412,5 +410,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(or1k_getsp(), running_task(), filename, lineno); board_crashdump(or1k_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -79,8 +79,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -108,7 +107,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -144,7 +142,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -180,5 +178,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(renesas_getsp(), running_task(), filename, lineno); board_crashdump(renesas_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -278,8 +278,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -308,7 +307,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -344,7 +342,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -384,5 +382,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(riscv_getsp(), running_task(), filename, lineno); board_crashdump(riscv_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -287,8 +287,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -323,7 +322,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -359,7 +357,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -415,5 +413,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(riscv_getsp(), running_task(), filename, lineno); board_crashdump(riscv_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -108,7 +108,7 @@ int main(int argc, char **argv, char **envp)
* *
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int line) void up_assert(const char *filename, int line)
{ {
/* Show the location of the failed assertion */ /* Show the location of the failed assertion */

View file

@ -246,8 +246,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -276,7 +275,6 @@ static void _up_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -288,7 +286,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -318,5 +316,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(x86_getsp(), running_task(), filename, lineno); board_crashdump(x86_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -52,6 +52,10 @@
# undef CONFIG_ARCH_USBDUMP # undef CONFIG_ARCH_USBDUMP
#endif #endif
#ifndef CONFIG_BOARD_RESET_ON_ASSERT
# define CONFIG_BOARD_RESET_ON_ASSERT 0
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -208,8 +212,7 @@ static void up_dumpstate(void)
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) noreturn_function; static void _up_assert(void)
static void _up_assert(int errorcode)
{ {
/* Are we in an interrupt handler or the idle task? */ /* Are we in an interrupt handler or the idle task? */
@ -218,6 +221,9 @@ static void _up_assert(int errorcode)
(void)up_irq_save(); (void)up_irq_save();
for (; ; ) for (; ; )
{ {
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif
#ifdef CONFIG_ARCH_LEDS #ifdef CONFIG_ARCH_LEDS
board_autoled_on(LED_PANIC); board_autoled_on(LED_PANIC);
up_mdelay(250); up_mdelay(250);
@ -228,7 +234,11 @@ static void _up_assert(int errorcode)
} }
else else
{ {
exit(errorcode); /* Assertions in other contexts only cause the thread to exit */
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif
} }
} }
@ -240,7 +250,7 @@ static void _up_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = this_task(); struct tcb_s *rtcb = this_task();
@ -262,5 +272,5 @@ void up_assert(const uint8_t *filename, int lineno)
board_crashdump(x64_getsp(), this_task(), filename, lineno); board_crashdump(x64_getsp(), this_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -101,8 +101,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: xtensa_assert * Name: xtensa_assert
****************************************************************************/ ****************************************************************************/
static void xtensa_assert(int errorcode) noreturn_function; static void xtensa_assert(void)
static void xtensa_assert(int errorcode)
{ {
/* Dump the processor state */ /* Dump the processor state */
@ -151,7 +150,6 @@ static void xtensa_assert(int errorcode)
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -163,7 +161,7 @@ static void xtensa_assert(int errorcode)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
void up_assert(const uint8_t *filename, int lineno) void up_assert(const char *filename, int lineno)
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -183,7 +181,7 @@ void up_assert(const uint8_t *filename, int lineno)
filename, lineno); filename, lineno);
#endif #endif
xtensa_assert(EXIT_FAILURE); xtensa_assert();
} }
/**************************************************************************** /****************************************************************************
@ -229,7 +227,7 @@ void xtensa_panic(int xptcode, uint32_t *regs)
#endif #endif
CURRENT_REGS = regs; CURRENT_REGS = regs;
xtensa_assert(EXIT_FAILURE); /* Should not return */ xtensa_assert(); /* Should not return */
for (; ; ); for (; ; );
} }
@ -334,6 +332,6 @@ void xtensa_user_panic(int exccause, uint32_t *regs)
#endif #endif
CURRENT_REGS = regs; CURRENT_REGS = regs;
xtensa_assert(EXIT_FAILURE); /* Should not return */ xtensa_assert(); /* Should not return */
for (; ; ); for (; ; );
} }

View file

@ -63,7 +63,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) /* noreturn_function */ static void _up_assert(void)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -92,7 +92,6 @@ static void _up_assert(int errorcode) /* noreturn_function */
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -128,11 +127,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_HAVE_FILENAME void up_assert(const char *filename, int lineno)
void up_assert(const uint8_t *filename, int lineno)
#else
void up_assert(void)
#endif
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -144,20 +139,12 @@ void up_assert(void)
syslog_flush(); syslog_flush();
#ifdef CONFIG_HAVE_FILENAME
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
_alert("Assertion failed at file:%s line: %d task: %s\n", _alert("Assertion failed at file:%s line: %d task: %s\n",
filename, lineno, rtcb->name); filename, lineno, rtcb->name);
#else #else
_alert("Assertion failed at file:%s line: %d\n", _alert("Assertion failed at file:%s line: %d\n",
filename, lineno); filename, lineno);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
_alert("Assertion failed: task: %s\n", rtcb->name);
#else
_alert("Assertion failed\n");
#endif
#endif #endif
z16_registerdump(); z16_registerdump();
@ -177,5 +164,5 @@ void up_assert(void)
board_crashdump(z16_getsp(), running_task(), filename, lineno); board_crashdump(z16_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -62,7 +62,7 @@
* Name: _up_assert * Name: _up_assert
****************************************************************************/ ****************************************************************************/
static void _up_assert(int errorcode) /* noreturn_function */ static void _up_assert(void)
{ {
/* Flush any buffered SYSLOG data */ /* Flush any buffered SYSLOG data */
@ -91,7 +91,6 @@ static void _up_assert(int errorcode) /* noreturn_function */
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 #if CONFIG_BOARD_RESET_ON_ASSERT >= 2
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
#endif #endif
exit(errorcode);
} }
} }
@ -127,11 +126,7 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
* Name: up_assert * Name: up_assert
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_HAVE_FILENAME void up_assert(const char *filename, int lineno)
void up_assert(const uint8_t *filename, int lineno)
#else
void up_assert(void)
#endif
{ {
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = running_task(); struct tcb_s *rtcb = running_task();
@ -143,20 +138,12 @@ void up_assert(void)
syslog_flush(); syslog_flush();
#ifdef CONFIG_HAVE_FILENAME
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
_alert("Assertion failed at file:%s line: %d task: %s\n", _alert("Assertion failed at file:%s line: %d task: %s\n",
filename, lineno, rtcb->name); filename, lineno, rtcb->name);
#else #else
_alert("Assertion failed at file:%s line: %d\n", _alert("Assertion failed at file:%s line: %d\n",
filename, lineno); filename, lineno);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
_alert("Assertion failed: task: %s\n", rtcb->name);
#else
_alert("Assertion failed\n");
#endif
#endif #endif
REGISTER_DUMP(); REGISTER_DUMP();
@ -178,5 +165,5 @@ void up_assert(void)
board_crashdump(z80_getsp(), running_task(), filename, lineno); board_crashdump(z80_getsp(), running_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert();
} }

View file

@ -1,7 +1,8 @@
/**************************************************************************** /****************************************************************************
* include/assert.h * include/assert.h
* *
* Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt.
* All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. * Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
@ -60,9 +61,9 @@
#undef DEBUGVERIFY /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */ #undef DEBUGVERIFY /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */
#ifdef CONFIG_HAVE_FILENAME #ifdef CONFIG_HAVE_FILENAME
# define PANIC() up_assert((const uint8_t *)__FILE__, (int)__LINE__) # define PANIC() _assert(__FILE__, __LINE__)
#else #else
# define PANIC() up_assert() # define PANIC() _assert("unknown", 0)
#endif #endif
#define ASSERT(f) do { if (!(f)) PANIC(); } while (0) #define ASSERT(f) do { if (!(f)) PANIC(); } while (0)
@ -117,11 +118,7 @@ extern "C"
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_HAVE_FILENAME void _assert(FAR const char *filename, int linenum) noreturn_function;
void up_assert(FAR const uint8_t *filename, int linenum) noreturn_function;
#else
void up_assert(void) noreturn_function;
#endif
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -475,7 +475,7 @@ void up_exit() noreturn_function;
* *
****************************************************************************/ ****************************************************************************/
/* Prototype is in assert.h */ void up_assert(FAR const char *filename, int linenum);
/**************************************************************************** /****************************************************************************
* Name: up_schedule_sigaction * Name: up_schedule_sigaction

View file

@ -48,6 +48,10 @@
# include <assert.h> # include <assert.h>
#endif #endif
/* Now include architecture-specific types */
#include <arch/irq.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@ -118,10 +122,6 @@ typedef uint32_t irq_mapped_t;
typedef CODE int (*xcpt_t)(int irq, FAR void *context, FAR void *arg); typedef CODE int (*xcpt_t)(int irq, FAR void *context, FAR void *arg);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
/* Now include architecture-specific types */
#include <arch/irq.h>
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/

View file

@ -21,6 +21,7 @@
include $(TOPDIR)/Make.defs include $(TOPDIR)/Make.defs
include aio/Make.defs include aio/Make.defs
include assert/Make.defs
include audio/Make.defs include audio/Make.defs
include builtin/Make.defs include builtin/Make.defs
include dirent/Make.defs include dirent/Make.defs

View file

@ -0,0 +1,26 @@
############################################################################
# libs/libc/assert/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
CSRCS += lib_assert.c
# Add the assert directory to the build
DEPPATH += --dep-path assert
VPATH += :assert

View file

@ -0,0 +1,38 @@
/****************************************************************************
* libs/libc/assert/lib_assert.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/arch.h>
#include <assert.h>
#include <stdlib.h>
/****************************************************************************
* Public Functions
****************************************************************************/
void _assert(FAR const char *filename, int linenum)
{
up_assert(filename, linenum);
exit(EXIT_FAILURE);
}

View file

@ -178,7 +178,7 @@
"uname","sys/utsname.h","","int","FAR struct utsname *" "uname","sys/utsname.h","","int","FAR struct utsname *"
"unlink","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char *" "unlink","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char *"
"unsetenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *" "unsetenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *"
"up_assert","assert.h","","void","FAR const uint8_t *","int" "up_assert","nuttx/arch.h","","void","FAR const char *","int"
"vfork","unistd.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_ARCH_HAVE_VFORK)","pid_t" "vfork","unistd.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_ARCH_HAVE_VFORK)","pid_t"
"wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","FAR int *" "wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","FAR int *"
"waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int" "waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int"

Can't render this file because it has a wrong number of fields in line 2.