My tests show (with recent glibc version) that with TZ=UTC mktime will
return -1 for tm_isdst=1. For tm_isdst=0 and tm_isdst=-1 mktime returns the
same value.
IMHO, tm_isdst=0 makes the most sense for TZ=UTC as UTC does not support
DST.
On Wed, Apr 21, 2021 at 6:50 PM Richard Cochran
wrote:
>
On Wed, Apr 21, 2021 at 07:28:59PM +0200, Lars Munch wrote:
> My tests show (with recent glibc version) that with TZ=UTC mktime will
> return -1 for tm_isdst=1. For tm_isdst=0 and tm_isdst=-1 mktime returns the
> same value.
>
> IMHO, tm_isdst=0 makes the most sense for TZ=UTC as UTC does not supp
On Wed, Apr 21, 2021 at 11:51:55AM +, Geva, Erez wrote:
> Looks like the man page is not accurate.
> Looking in
> https://pubs.opengroup.org/onlinepubs/009695399/functions/mktime.html
Okay, I see now, in the man page we read:
The value specified in the tm_isdst field informs mktime()
) (DI PA DCP R&D 3)
Cc: Richard Cochran ;
linuxptp-devel@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH] Fix uninitialized variable in
nmea_scan_rmc
My Arch system does indeed have daylight saving set, but nmea.c forces the TZ
to UTC where a positive value of tm_isdst does not
: Michael Galassi
Cc: linuxptp-devel@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH] Fix uninitialized variable in
nmea_scan_rmc
Sorry for the noise. In my previous example I had by accident pasted a huge
number into the example. New example:
#include
#include
#include
int main
Cochran
> Sent: Tuesday, 20 April 2021 16:05
> To: Lars Munch
> Cc: linuxptp-devel@lists.sourceforge.net
> Subject: Re: [Linuxptp-devel] [PATCH] Fix uninitialized variable in
> nmea_scan_rmc
>
> On Tue, Apr 20, 2021 at 11:44:06AM +0200, Lars Munch wrote:
> > tm_isdst needs t
bug report in the
> relevant packages/systems.
>
>
>
> Erez
>
>
>
>
>
> *From:* Lars Munch
> *Sent:* Tuesday, 20 April 2021 22:24
> *To:* Michael Galassi
> *Cc:* linuxptp-devel@lists.sourceforge.net
> *Subject:* Re: [Linuxptp-devel] [PATCH] Fix uninitializ
Message-
From: Richard Cochran
Sent: Tuesday, 20 April 2021 16:05
To: Lars Munch
Cc: linuxptp-devel@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH] Fix uninitialized variable in
nmea_scan_rmc
On Tue, Apr 20, 2021 at 11:44:06AM +0200, Lars Munch wrote:
> tm_isdst needs to
I think that no matter what any particular implementation might do, we are
relying on undefined behavior which is at best unsafe. I wonder if maybe
we shouldn't consider initializing the entire structure (and all others?)
after it is allocated. The performance price feels small and the safety
gua
Sorry for the noise. In my previous example I had by accident pasted a huge
number into the example. New example:
#include
#include
#include
int main()
{
struct tm t;
time_t now = time((void*)0);
localtime_r(&now, &t);
setenv("TZ", "UTC", 1);
t.tm_isdst = 1;
printf("%ld
Indeed, any positive random number in tm.tm_isdst will set DST in effect it
seems.
On my stripped down ARM system with no timezone information, it will simply
return -1.
On Tue, Apr 20, 2021 at 4:26 PM Michael Galassi wrote:
> Somewhere lies a bug. The following code snippet:
> #include
> #in
Ok, so mktime is forced to return in time UTC time scale earlier in the
code:
#include
#include
#include
int main()
{
struct tm t;
time_t now = time((void*)0);
localtime_r(&now, &t);
setenv("TZ", "UTC", 1);
t.tm_isdst = 41;
printf("%ld\n", mktime(&t));
t.tm_
Somewhere lies a bug. The following code snippet:
#include
#include
int main()
{
struct tm t;
time_t now = time((void*)0);
localtime_r(&now, &t);
t.tm_isdst = 1;
printf("%ld\n", mktime(&t));
t.tm_isdst = 0;
printf("%ld\n", mktime(&t));
t.tm_isdst = -1;
printf(
On Tue, Apr 20, 2021 at 11:44:06AM +0200, Lars Munch wrote:
> tm_isdst needs to be initialized to make sure mktime does not fail
> or calculates the wrong time.
No, take a look at the mktime(3) man page. There you will read the
following.
The mktime() function modifies the fields of the
tm_isdst needs to be initialized to make sure mktime does not fail
or calculates the wrong time.
Signed-off-by: Lars Munch
---
nmea.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/nmea.c b/nmea.c
index dc865d0..44c7c01 100644
--- a/nmea.c
+++ b/nmea.c
@@ -157,6 +157,7 @@ static int nmea_sc
15 matches
Mail list logo