This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 0916f1a5619 libs/libc/time: Set tm_zone to "UTC" in gmtime_r().
0916f1a5619 is described below

commit 0916f1a5619cb6fab29e41f179a61d0140b71417
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 9 13:47:34 2026 +0200

    libs/libc/time: Set tm_zone to "UTC" in gmtime_r().
    
    Without CONFIG_LIBC_LOCALTIME, gmtime_r() (and localtime_r(), which
    uses it) set tm_zone to NULL.  Programs print it as the time zone name,
    for example strftime() implementations that format %Z from tm_zone,
    and call strlen() on it, which faults.
    
    Set it to "UTC", as the time zone code of CONFIG_LIBC_LOCALTIME does
    for UTC.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 libs/libc/time/lib_gmtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/libc/time/lib_gmtimer.c b/libs/libc/time/lib_gmtimer.c
index c9c6085218b..ddb32ba7813 100644
--- a/libs/libc/time/lib_gmtimer.c
+++ b/libs/libc/time/lib_gmtimer.c
@@ -337,7 +337,7 @@ FAR struct tm *gmtime_r(FAR const time_t *timep, FAR struct 
tm *result)
                                             clock_isleapyear(year));
   result->tm_isdst  = 0;
   result->tm_gmtoff = 0;
-  result->tm_zone   = NULL;
+  result->tm_zone   = "UTC";
 
   return result;
 }

Reply via email to