Skip to content

Question on gf_time_fmt_tv() - what's the check for 'if (tv->tv_sec ...' for? #2802

Answered by csabahenk
mykaul asked this question in Q&A
Discussion options

You must be logged in to vote

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 stub gettimeofday()).

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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by csabahenk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants