[PATCH] lwip: provide a sntp_format_time() function

Jerome Forissier jerome.forissier at linaro.org
Wed Jul 30 12:11:31 CEST 2025


Provide a trivial implementation of sntp_format_time() to fix a build
error when CONFIG_LWIP_DEBUG=y:

lib/lwip/lwip/src/apps/sntp/sntp.c: In function ‘sntp_format_time’:
lib/lwip/lwip/src/apps/sntp/sntp.c:283:10: error: implicit declaration of function ‘ctime’ [-Werror=implicit-function-declaration]
  283 |   return ctime(&ut);
      |          ^~~~~

Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
---

 lib/lwip/u-boot/arch/cc.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/lwip/u-boot/arch/cc.h b/lib/lwip/u-boot/arch/cc.h
index f91127ac565..92476db7502 100644
--- a/lib/lwip/u-boot/arch/cc.h
+++ b/lib/lwip/u-boot/arch/cc.h
@@ -47,4 +47,12 @@
 void sntp_set_system_time(uint32_t sec);
 #define SNTP_SET_SYSTEM_TIME(sec) sntp_set_system_time(sec)
 
+static inline const char *sntp_format_time(time_t t)
+{
+	static char buf[29]; /* "(time_t)" + 20 digits max + \0 */
+
+	snprintf(buf, sizeof(buf), "(time_t)%llu", t);
+	return buf;
+}
+#define sntp_format_time sntp_format_time
 #endif /* LWIP_ARCH_CC_H */
-- 
2.43.0

base-commit: a8f20bb6650df56d2600cda2c66f9349df9e49c8
branch: lwip-debug-fix


More information about the U-Boot mailing list