Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5693 closed defect (fixed)

time_t var brokenDown might want to init tm_gmtoff and tm_zone

Reported by: Erik Hovland <erik@…> Owned by: Isaac Richards
Priority: trivial Milestone: unknown
Component: mythtv Version: head
Severity: low Keywords:
Cc: Ticket locked: no

Description

Glibc (and supposedly *BSD libc) have additional struct members tm_gmtoff and tm_zone in time_t. There are also the members tm_wday and tm_yday (that every Unix has). They are not initialized in toTime_t.

Attachments (2)

programs_mythfilldatabase-uninit.patch (1.1 KB) - added by Erik Hovland <erik@…> 11 years ago.
init some more struct member vars in toTime_t
programs_mythfilldatabase-uninit-ticket-5693.patch (1.1 KB) - added by Erik Hovland <erik@…> 11 years ago.
changes the initialization to conform to danielk's suggestion

Download all attachments as: .zip

Change History (8)

Changed 11 years ago by Erik Hovland <erik@…>

init some more struct member vars in toTime_t

comment:1 Changed 11 years ago by danielk

Status: newinfoneeded_new

Erik, I think that ::timezone and ::tzname[0] will return the localtime values instead of UTC, which from the naming of the secsSince1Jan1970UTC variable is what I assume we want. Would simply doing a bzero be appropriate in this case?

comment:2 Changed 11 years ago by Erik Hovland <erik@…>

Yes, just zeroing out would be enough.

Changed 11 years ago by Erik Hovland <erik@…>

changes the initialization to conform to danielk's suggestion

comment:3 Changed 11 years ago by Erik Hovland <erik@…>

I have resubmitted the patch to initialize those two fields with more sane values. Please keep the cast there as this is required for 64-bit correctness. This is because in C++ null evaluates to 0 which is then turned into a uint32_t. If it isn't cast then the compiler is welcome to put any bits it wants into the upper 32-bits on 64-bit OSes.

comment:4 Changed 11 years ago by danielk

Resolution: fixed
Status: infoneeded_newclosed

(In [19453]) Fixes #5693. Make sure time structure is fully initialized.

comment:5 Changed 11 years ago by danielk

I kept the cast, but I think any compiler that didn't handle NULL appropriately would be taken out and tarred :)

comment:6 Changed 11 years ago by Erik Hovland <erik@…>

I hear you. But this is a C++ issue. Just look on the intertubes for gcc and sentinel warnings.

Note: See TracTickets for help on using tickets.