-
Snippet:
What's the purpose of the tv->tv_sec check? in both cases of localtime_r() or gmtime_r(), they don't change the variable. tv is passed as a variable to this function from various callers, who usually fill it with gettimeofday() result. @csabahenk , any idea? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As the purpose of this function is to format Epoch times, a zero This logic was inherited from the previous time formatting code, prior to 8cb23ee. This change was as conservative as possible along with achieving its goals (see the This change does *not* do the following part of the commit message), therefore this logic wasn't supervised either. |
Beta Was this translation helpful? Give feedback.
As the purpose of this function is to format Epoch times, a zero
tv_sec
quite reliably indicates a dummy time value (ie. it's unlikely we'd want to give account of the events happened in the first second of Epoch). So via this the function allows callers to pass in a stub time value. I'm not sure if this is used anywhere; a possible use case would be by test cases that want to check for the presence of certain log lines and want predictable log output (this would require ld-preloading a stubgettimeofday()
).This logic was inherited from the previous time formatting code, prior to 8cb23ee. This change was as conservative as possible along with achieving its goals (see the This change does…