You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/08/05 02:42:28 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6783: libc/localtime: fix ats over time_t range

xiaoxiang781216 commented on code in PR #6783:
URL: https://github.com/apache/incubator-nuttx/pull/6783#discussion_r938396437


##########
libs/libc/time/lib_localtime.c:
##########
@@ -676,23 +668,22 @@ static int tzload(FAR const char *name,
       for (i = 0; i < sp->timecnt; ++i)
         {
           int_fast64_t at = stored == 4 ? detzcode(p) : detzcode64(p);
-          sp->types[i] = ((TYPE_SIGNED(time_t)
-                           ? g_min_timet <= at : 0 <= at) &&
-                           at <= g_max_timet);
+          sp->types[i] = at <= g_max_timet;
           if (sp->types[i])
             {
-              if (i && !timecnt && at != g_min_timet)
+              int_fast64_t attime = at < g_min_timet ? g_min_timet : at;

Review Comment:
   The code in https://github.com/eggert/tz/blob/main/localtime.c can work correctly only when time_t is 64bits in the internal computation. Since NuttX define time_t as uint32_t, we need modify the internal function/data to int_fast64_t.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org