diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-10-14 13:13:00 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-10-15 15:07:40 +0200 |
commit | 28d8a59d9cd3819dc558e397a6b14cef17c55245 (patch) | |
tree | 6e9b58db8172fd4c428e926fde282be3a845ec24 /sal/osl | |
parent | 570261954089695377cd6910b95fd3b6ee864062 (diff) |
cid#1557682 alt fix for Initialization or destruction ordering is unspecified
Change-Id: Ibbcc3808a7a7ec71a046b263757506f61ac48093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174970
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/all/log.cxx | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx index 96afdd68c810..6d6e808e7446 100644 --- a/sal/osl/all/log.cxx +++ b/sal/osl/all/log.cxx @@ -55,16 +55,14 @@ bool const sal_use_syslog = false; namespace { -struct TimeContainer +TimeValue GetTime() { TimeValue aTime; - TimeContainer() - { - osl_getSystemTime(&aTime); - } -}; + osl_getSystemTime(&aTime); + return aTime; +} -TimeContainer aStartTime; +const TimeValue aStartTime = GetTime(); bool equalStrings( char const * string1, std::size_t length1, char const * string2, @@ -276,26 +274,21 @@ void maybeOutputTimestamp(std::ostringstream &s) { s << ts << '.' << milliSecs << ':'; } -// disable this fairly obscure feature when building with coverity -// to avoid a bazillion 'Initialization or destruction ordering is unspecified' -// warnings about the use of aStartTime -#if !defined(__COVERITY__) || __COVERITY_MAJOR__ > 2023 if (outputRelativeTimer) { - int seconds = now.Seconds - aStartTime.aTime.Seconds; + int seconds = now.Seconds - aStartTime.Seconds; int milliSeconds; - if (now.Nanosec < aStartTime.aTime.Nanosec) + if (now.Nanosec < aStartTime.Nanosec) { seconds--; - milliSeconds = 1000 - (aStartTime.aTime.Nanosec - now.Nanosec) / 1000000; + milliSeconds = 1000 - (aStartTime.Nanosec - now.Nanosec) / 1000000; } else - milliSeconds = (now.Nanosec - aStartTime.aTime.Nanosec) / 1000000; + milliSeconds = (now.Nanosec - aStartTime.Nanosec) / 1000000; char relativeTimestamp[100]; snprintf(relativeTimestamp, sizeof(relativeTimestamp), "%d.%03d", seconds, milliSeconds); s << relativeTimestamp << ':'; } -#endif } #endif |