Skip to content

Commit dff2192

Browse files
anchaoxiaoxiang781216
authored andcommitted
misc/assert: remove const string from assert expression
Signed-off-by: chao an <[email protected]>
1 parent 247b050 commit dff2192

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

include/assert.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#undef DEBUGVERIFY /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */
4444

4545
#ifndef CONFIG_HAVE_FILENAME
46-
# define __FILE__ "unknown"
46+
# define __FILE__ NULL
4747
# define __LINE__ 0
4848
#endif
4949

@@ -53,8 +53,8 @@
5353
#define ASSERT(f) do { if (!(f)) __assert(__FILE__, __LINE__, #f); } while (0)
5454
#define VERIFY(f) do { if ((f) < 0) __assert(__FILE__, __LINE__, #f); } while (0)
5555
#else
56-
#define ASSERT(f) do { if (!(f)) __assert(__FILE__, __LINE__, "unknown"); } while (0)
57-
#define VERIFY(f) do { if ((f) < 0) __assert(__FILE__, __LINE__, "unknown"); } while (0)
56+
#define ASSERT(f) do { if (!(f)) __assert(__FILE__, __LINE__, NULL); } while (0)
57+
#define VERIFY(f) do { if ((f) < 0) __assert(__FILE__, __LINE__, NULL); } while (0)
5858
#endif
5959

6060
#ifdef CONFIG_DEBUG_ASSERTIONS

sched/misc/assert.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -469,24 +469,24 @@ void _assert(FAR const char *filename, int linenum, FAR const char *msg)
469469
name.sysname, name.nodename,
470470
name.release, name.version, name.machine);
471471

472+
_alert("Assertion failed %s: at file: %s:%d task"
472473
#ifdef CONFIG_SMP
473-
# if CONFIG_TASK_NAME_SIZE > 0
474-
_alert("Assertion failed: %s at file: %s:%d task(CPU%d): %s %p\n",
475-
msg, filename, linenum, up_cpu_index(), rtcb->name,
476-
rtcb->entry.main);
477-
# else
478-
_alert("Assertion failed: %s at file: %s:%d task(CPU%d): %p\n",
479-
msg, filename, linenum, up_cpu_index(), rtcb->entry.main);
480-
# endif
481-
#else
482-
# if CONFIG_TASK_NAME_SIZE > 0
483-
_alert("Assertion failed: %s at file: %s:%d task: %s %p\n",
484-
msg, filename, linenum, rtcb->name, rtcb->entry.main);
485-
# else
486-
_alert("Assertion failed: %s at file: %s:%d task: %p\n",
487-
msg, filename, linenum, rtcb->entry.main);
488-
# endif
474+
"(CPU%d)"
489475
#endif
476+
": "
477+
#if CONFIG_TASK_NAME_SIZE > 0
478+
"%s "
479+
#endif
480+
"%p\n",
481+
msg ? msg : "",
482+
filename ? filename : "", linenum,
483+
#ifdef CONFIG_SMP
484+
up_cpu_index(),
485+
#endif
486+
#if CONFIG_TASK_NAME_SIZE > 0
487+
rtcb->name,
488+
#endif
489+
rtcb->entry.main);
490490

491491
/* Show back trace */
492492

0 commit comments

Comments
 (0)