You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2021/07/02 16:27:34 UTC
[incubator-nuttx] 06/09: libc/time: Update g_lcl_tzname only after
the success
This is an automated email from the ASF dual-hosted git repository.
davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit dcad420127669d489cef8109b61fb7a1902189e2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Jun 21 02:45:30 2021 +0800
libc/time: Update g_lcl_tzname only after the success
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: I0117c5b43bee3affb36d118e0b97f6dd7137080b
---
libs/libc/time/lib_localtime.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c
index 647ce51..d3fc99b 100644
--- a/libs/libc/time/lib_localtime.c
+++ b/libs/libc/time/lib_localtime.c
@@ -2532,19 +2532,12 @@ void tzset(void)
goto out;
}
- g_lcl_isset = strlen(name) < sizeof g_lcl_tzname;
- if (g_lcl_isset)
- {
- strcpy(g_lcl_tzname, name);
- }
-
if (lclptr == NULL)
{
lclptr = lib_malloc(sizeof *lclptr);
if (lclptr == NULL)
{
- settzname(); /* all we can do */
- goto out;
+ goto tzname;
}
}
@@ -2565,11 +2558,18 @@ void tzset(void)
if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
{
gmtload(lclptr);
+ goto tzname;
}
}
- settzname();
+ g_lcl_isset = strlen(name) < sizeof g_lcl_tzname;
+ if (g_lcl_isset)
+ {
+ strcpy(g_lcl_tzname, name);
+ }
+tzname:
+ settzname();
out:
tz_semgive(&g_lcl_sem);
}