nuttx-apps/testing/cmocka/0001-cmocka.c-Reduce-the-call-stack-consumption-of-printf.patch

60 lines
1.7 KiB
Diff
Raw Normal View History

From a5e95907fbf6921668abc4a61641d28a16a88c81 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Fri, 6 Jan 2023 10:09:20 +0800
Subject: [PATCH 1/2] cmocka.c: Reduce the call stack consumption of printf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idf179ad5eb81bbc63eea4f71980857831668e7a8
---
src/cmocka.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/cmocka.c cmocka/src/cmocka.c
index ef8fbd9..ff59b53 100644
--- a/src/cmocka.c
+++ cmocka/src/cmocka.c
@@ -2086,7 +2086,7 @@ static void vcmocka_print_error(const char* const format,
*/
static void vcmocka_print_error(const char* const format, va_list args)
{
- char buffer[1024];
+ char buffer[256];
size_t msg_len = 0;
va_list ap;
int len;
@@ -2427,12 +2427,12 @@ void cmocka_print_error(const char * const format, ...)
/* Standard output and error print methods. */
void vprint_message(const char* const format, va_list args)
{
+ vprintf(format, args);
+ fflush(stdout);
+#ifdef _WIN32
char buffer[4096];
vsnprintf(buffer, sizeof(buffer), format, args);
- printf("%s", buffer);
- fflush(stdout);
-#ifdef _WIN32
OutputDebugString(buffer);
#endif /* _WIN32 */
}
@@ -2440,12 +2440,12 @@ void vprint_message(const char* const format, va_list args)
void vprint_error(const char* const format, va_list args)
{
+ vfprintf(stderr, format, args);
+ fflush(stderr);
+#ifdef _WIN32
char buffer[4096];
vsnprintf(buffer, sizeof(buffer), format, args);
- fprintf(stderr, "%s", buffer);
- fflush(stderr);
-#ifdef _WIN32
OutputDebugString(buffer);
#endif /* _WIN32 */
}
--
2.25.1