Skip to content

g_file_info_get_modification_date_time: Calculate in integer domain

Simon McVittie requested to merge smcv/glib:exact-mtime into master

g_date_time_add_seconds() and g_date_time_add_full() use floating-point seconds, which can result in the value varying slightly from what's actually on disk. This causes intermittent test failures in gio/tests/g-file-info.c on Debian i386, where we set a file's mtime to be 50µs later, then read it back and sometimes find that it is only 49µs later than the previous value.

I've only seen this happen on i386, which means it might be to do with different floating-point rounding when a value is stored in the 80-bit legacy floating point registers rather than in double precision.

g_date_time_add() takes a GTimeSpan, which is in microseconds; conveniently, that's exactly what we get from the GFileInfo.

Bug-Debian: https://bugs.debian.org/941547


Exposed by 475b9b5f. Please cherry-pick to 2.62 branch if accepted.

Edited by Simon McVittie

Merge request reports