gustavonihei commented on a change in pull request #4270:
URL: https://github.com/apache/incubator-nuttx/pull/4270#discussion_r682850775
##########
File path: libs/libc/time/lib_localtime.c
##########
@@ -2528,9 +2537,20 @@ void tzset(void)
{
FAR const char *name;
- tz_semtake(&g_lcl_sem);
-
name = getenv("TZ");
+ if (g_lcl_isset > 0 && name && strcmp(g_lcl_tzname, name) == 0)
+ {
+ return;
+ }
Review comment:
I think I've finally understood why you added the first check. But only
after I compared to the fix applied to `gmtsub`.
There, the same "redundant" check has been applied, but on `gmtsub` is not
really redundant.
On `gmtsub` the global variable `g_gmt_isset` is verified because, even if
executing in interrupt context, the function is able to perform the subtraction
because the timezone is already initialized.
But on `tzset` the verification is indeed redundant, for the reasons I've
explained before. When executing in interrupt context, `tzset` will just return
early without returning anything, regardless of whether the timezone is already
initialized or not. So the first check could be safely removed.
Is this correct?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]