From ebbf34b2663bb4b4de254f46aa76aadec008fa44 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Mon, 12 Jul 2021 10:32:18 +0100 Subject: [PATCH] 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. --- libs/ardour/vst2_scan.cc | 3 ++- libs/ardour/vst3_scan.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/ardour/vst2_scan.cc b/libs/ardour/vst2_scan.cc index b2b45ae169..14f0854fc3 100644 --- a/libs/ardour/vst2_scan.cc +++ b/libs/ardour/vst2_scan.cc @@ -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 = " diff --git a/libs/ardour/vst3_scan.cc b/libs/ardour/vst3_scan.cc index e703221d60..23a81e5fbb 100644 --- a/libs/ardour/vst3_scan.cc +++ b/libs/ardour/vst3_scan.cc @@ -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 = "