From 9c2a17a14d55781199aec60474151ec38bf96c25 Mon Sep 17 00:00:00 2001
From: anjiahao <anjiahao@xiaomi.com>
Date: Thu, 14 Nov 2024 17:26:36 +0800
Subject: [PATCH] remove <nuttx/xxx.h> in stdio need add depend header file

Error: cmocka/src/cmocka.c:2568:9: error: implicit declaration of function 'ftruncate'; did you mean 'strncat'? [-Werror=implicit-function-declaration]
     2568 |         ftruncate(fileno(fp), ftell(fp));
          |         ^~~~~~~~~
          |         strncat

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
---
 ...uttx-xxx.h-in-stdio-need-add-depend-header-f.patch | 11 +++++++++++
 testing/cmocka/CMakeLists.txt                         |  2 ++
 testing/cmocka/Makefile                               |  1 +
 3 files changed, 14 insertions(+)
 create mode 100644 testing/cmocka/0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch

diff --git a/testing/cmocka/0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch b/testing/cmocka/0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch
new file mode 100644
index 00000000000..62ba6219b12
--- /dev/null
+++ b/testing/cmocka/0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch
@@ -0,0 +1,11 @@
+diff --color -ur cmocka_bak/src/cmocka.c cmocka/src/cmocka.c
+--- cmocka_bak/src/cmocka.c	2024-11-14 15:50:02.013648944 +0800
++++ cmocka/src/cmocka.c	2024-11-14 15:50:23.136212001 +0800
+@@ -48,6 +48,7 @@
+ #include <regex.h>
+ #include <mqueue.h>
+ #include <fcntl.h>
++#include <unistd.h>
+ 
+ /*
+  * This allows to add a platform specific header file. Some embedded platforms
diff --git a/testing/cmocka/CMakeLists.txt b/testing/cmocka/CMakeLists.txt
index 11568513eeb..df8ef7ba416 100644
--- a/testing/cmocka/CMakeLists.txt
+++ b/testing/cmocka/CMakeLists.txt
@@ -43,6 +43,8 @@ if(CONFIG_TESTING_CMOCKA)
         ${CMAKE_CURRENT_LIST_DIR}/0005-cmocka-cmocka_private-fix-warning-in-cmocka_private.patch
         && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR}/cmocka <
         ${CMAKE_CURRENT_LIST_DIR}/0006-fix-linux-risc-v-compile-error-list_initialize.patch
+        && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR}/cmocka <
+        ${CMAKE_CURRENT_LIST_DIR}/0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch
       DOWNLOAD_NO_PROGRESS true
       TIMEOUT 30)
 
diff --git a/testing/cmocka/Makefile b/testing/cmocka/Makefile
index c2694f6c527..b479c8409b9 100644
--- a/testing/cmocka/Makefile
+++ b/testing/cmocka/Makefile
@@ -47,6 +47,7 @@ cmocka.zip:
 	$(Q) patch -p0 < 0004-cmocka-xml-report.patch
 	$(Q) patch -p0 < 0005-cmocka-cmocka_private-fix-warning-in-cmocka_private.patch
 	$(Q) patch -p0 < 0006-fix-linux-risc-v-compile-error-list_initialize.patch
+	$(Q) patch -p0 < 0007-remove-nuttx-xxx.h-in-stdio-need-add-depend-header-f.patch
 
 context:: cmocka.zip