mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-09 08:18:09 +02:00
log: print dummy timestamp if localtime call fails
Handle the case where localtime fails (NULL) and print something else to indicate localtime is erroneous. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
This commit is contained in:
parent
981fa33809
commit
1db007202b
1 changed files with 3 additions and 0 deletions
|
|
@ -46,6 +46,9 @@ static int weston_log_timestamp(void)
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
brokendown_time = localtime(&tv.tv_sec);
|
brokendown_time = localtime(&tv.tv_sec);
|
||||||
|
if (brokendown_time == NULL)
|
||||||
|
return fprintf(weston_logfile, "[(NULL)localtime] ");
|
||||||
|
|
||||||
if (brokendown_time->tm_mday != cached_tm_mday) {
|
if (brokendown_time->tm_mday != cached_tm_mday) {
|
||||||
strftime(string, sizeof string, "%Y-%m-%d %Z", brokendown_time);
|
strftime(string, sizeof string, "%Y-%m-%d %Z", brokendown_time);
|
||||||
fprintf(weston_logfile, "Date: %s\n", string);
|
fprintf(weston_logfile, "Date: %s\n", string);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue