You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/07 17:38:18 UTC
[incubator-nuttx-apps] branch master updated: system/note: correct unflatten format
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 8c1a4994c system/note: correct unflatten format
8c1a4994c is described below
commit 8c1a4994ccca73b12245341bb68f00086f1a4040
Author: chao.an <an...@xiaomi.com>
AuthorDate: Wed Apr 6 16:53:19 2022 +0800
system/note: correct unflatten format
Signed-off-by: chao.an <an...@xiaomi.com>
---
system/sched_note/note_main.c | 26 +++++++-------------------
system/trace/trace_dump.c | 26 +++++++-------------------
2 files changed, 14 insertions(+), 38 deletions(-)
diff --git a/system/sched_note/note_main.c b/system/sched_note/note_main.c
index 3bef03142..352a6d502 100644
--- a/system/sched_note/note_main.c
+++ b/system/sched_note/note_main.c
@@ -90,27 +90,15 @@ static FAR const char *g_statenames[] =
static void trace_dump_unflatten(FAR void *dst,
FAR uint8_t *src, size_t len)
{
- switch (len)
+#ifdef CONFIG_ENDIAN_BIG
+ FAR uint8_t *end = (FAR uint8_t *)dst + len - 1;
+ while (len-- > 0)
{
-#ifdef CONFIG_HAVE_LONG_LONG
- case 8:
- *(uint64_t *)dst = ((uint64_t)src[7] << 56)
- + ((uint64_t)src[6] << 48)
- + ((uint64_t)src[5] << 40)
- + ((uint64_t)src[4] << 32);
-#endif
- case 4:
- *(uint32_t *)dst = ((uint64_t)src[3] << 24)
- + ((uint64_t)src[2] << 16);
- case 2:
- *(uint16_t *)dst = ((uint64_t)src[1] << 8);
- case 1:
- *(uint8_t *)dst = src[0];
- break;
- default:
- DEBUGASSERT(FALSE);
- break;
+ *end-- = *src++;
}
+#else
+ memcpy(dst, src, len);
+#endif
}
/************************************************************************************
diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c
index 7fbc46bf6..46399f147 100644
--- a/system/trace/trace_dump.c
+++ b/system/trace/trace_dump.c
@@ -109,27 +109,15 @@ struct trace_dump_context_s
static void trace_dump_unflatten(FAR void *dst,
FAR uint8_t *src, size_t len)
{
- switch (len)
+#ifdef CONFIG_ENDIAN_BIG
+ FAR uint8_t *end = (FAR uint8_t *)dst + len - 1;
+ while (len-- > 0)
{
-#ifdef CONFIG_HAVE_LONG_LONG
- case 8:
- *(uint64_t *)dst = ((uint64_t)src[7] << 56)
- + ((uint64_t)src[6] << 48)
- + ((uint64_t)src[5] << 40)
- + ((uint64_t)src[4] << 32);
-#endif
- case 4:
- *(uint32_t *)dst = ((uint64_t)src[3] << 24)
- + ((uint64_t)src[2] << 16);
- case 2:
- *(uint16_t *)dst = ((uint64_t)src[1] << 8);
- case 1:
- *(uint8_t *)dst = src[0];
- break;
- default:
- DEBUGASSERT(FALSE);
- break;
+ *end-- = *src++;
}
+#else
+ memcpy(dst, src, len);
+#endif
}
/****************************************************************************