Pass 'localtime_r()' the correct form of 'time_t'

Even for a 32-bit build, MSVC expects 'time_t' to be 64-bit - whereas Glib (i.e. GStatBuf) seems to be using a 32-bit version. Since we're passing by address, this will cause problems in a Windows build.

We can kludge this by making sure we pass the expected type for 'time_t'. Ultimately though, it'd be safer to adapt 'localtime_r()' to accept its first parameter by value, rather than expecting a pointer.
This commit is contained in:
John Emmas 2021-07-12 10:32:18 +01:00
parent 40c698340d
commit ebbf34b266
2 changed files with 4 additions and 2 deletions

View File

@ -638,12 +638,13 @@ touch_cachefile (std::string const& path, std::string const& cache_file, bool ve
if (0 != g_utime (cache_file.c_str (), &utb)) {
PBD::error << "Could not set cachefile timestamp." << endmsg;
} else if (verbose) {
const time_t mtime = sb_vst.st_mtime;
char v2itme[128];
char vsttme[128];
struct tm local_time;
localtime_r (&utb.modtime, &local_time);
strftime (v2itme, sizeof(v2itme), "%Y-%m-%d %T", &local_time);
localtime_r (&sb_vst.st_mtime, &local_time);
localtime_r (&mtime, &local_time);
strftime (vsttme, sizeof(vsttme), "%Y-%m-%d %T", &local_time);
PBD::info << "Touch cachefile: set mtime = "
<< utb.modtime << " (" << v2itme << "), plugin mtime = "

View File

@ -421,12 +421,13 @@ touch_cachefile (std::string const& module_path, std::string const& cache_file,
if (0 != g_utime (cache_file.c_str (), &utb)) {
PBD::error << "Could not set cachefile timestamp." << endmsg;
} else if (verbose) {
const time_t mtime = sb_vst.st_mtime;
char v3itme[128];
char vsttme[128];
struct tm local_time;
localtime_r (&utb.modtime, &local_time);
strftime (v3itme, sizeof(v3itme), "%Y-%m-%d %T", &local_time);
localtime_r (&sb_vst.st_mtime, &local_time);
localtime_r (&mtime, &local_time);
strftime (vsttme, sizeof(vsttme), "%Y-%m-%d %T", &local_time);
PBD::info << "Touch cachefile: set mtime = "
<< utb.modtime << " (" << v3itme << "), plugin mtime = "