diff options
| author | armink <[email protected]> | 2021-04-12 22:16:17 +0800 |
|---|---|---|
| committer | armink <[email protected]> | 2021-04-15 14:10:27 +0800 |
| commit | 3ae6ca1fb09a1ec254285f8e5522e8d233f1c85c (patch) | |
| tree | a4a4c876528c012796eb56db37825a502264c2dc /components/utilities | |
| parent | b7a5319e5c220b07190db2bf38ff362e403226bb (diff) | |
[ulog] Fix thread info show when kernel not startup.
Diffstat (limited to 'components/utilities')
| -rw-r--r-- | components/utilities/ulog/ulog.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index e903a707b2..4952da4007 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -318,9 +318,12 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta /* is not in interrupt context */ if (rt_interrupt_get_nest() == 0) { - rt_size_t name_len = rt_strnlen(rt_thread_self()->name, RT_NAME_MAX); - - rt_strncpy(log_buf + log_len, rt_thread_self()->name, name_len); + rt_size_t name_len = 0; + const char *thread_name = "N/A"; + if (rt_thread_self()->name) + thread_name = rt_thread_self()->name; + name_len = rt_strnlen(thread_name, RT_NAME_MAX); + rt_strncpy(log_buf + log_len, thread_name, name_len); log_len += name_len; } else |
