gustavonihei commented on a change in pull request #4270:
URL: https://github.com/apache/incubator-nuttx/pull/4270#discussion_r682836365
##########
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:
Honestly, I don't know.
The point I am having trouble to understand is why is the first check
needed, this one:
```c
if (g_lcl_isset > 0 && name && strcmp(g_lcl_tzname, name) == 0)
{
return;
}
```
In my mind right now there is the following question: Why isn't the fix just
the addition of the following check in the function entry:
```c
#ifndef __KERNEL__
if (up_interrupt_context())
{
return;
}
#endif
```
Because the code paths I am considering are:
1) If it's executing in interrupt context, the function will return either
by the first or by the second condition.
2) If it's executing in user/process context, it will check the global
variables twice, first without locking the semaphore (not thread-safe) and
second by locking the semaphore (thread-safe).
--
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]