summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-18 15:54:12 +0100
committerAndras Timar <andras.timar@collabora.com>2019-10-06 18:56:07 +0200
commit297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42 (patch)
tree343db814deac95588517057689b985529379c365 /extensions
parentjsdialogs: hide one number format option initially (diff)
downloadcore-297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42.tar.gz
core-297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42.zip
Avoid -Werror=format-{overflow,truncation}=
...as emitted by at least GCC 8.2 with --enable-optimized, by making the buffers large enough for the (hypothetical) largest values of the various date/time components Change-Id: I82e9b08fa099546b2d6f29c702e1440df9e6c6e0 Reviewed-on: https://gerrit.libreoffice.org/66618 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/logging/plaintextformatter.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx
index 6691ee17b060..2f5096ea510b 100644
--- a/extensions/source/logging/plaintextformatter.cxx
+++ b/extensions/source/logging/plaintextformatter.cxx
@@ -79,7 +79,8 @@ namespace logging
OUString SAL_CALL PlainTextFormatter::format( const LogRecord& _rRecord )
{
- char buffer[ 30 ];
+ char buffer[ sizeof("-32768-65535-65535 65535:65535:65535.4294967295") ];
+ // reserve enough space for hypothetical max length
const int buffer_size = sizeof( buffer );
int used = snprintf( buffer, buffer_size, "%10i", static_cast<int>(_rRecord.SequenceNumber) );
if ( used >= buffer_size || used < 0 )
@@ -94,9 +95,9 @@ namespace logging
aLogEntry.appendAscii( buffer );
aLogEntry.append( " " );
- snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i",
- static_cast<int>(_rRecord.LogTime.Year), static_cast<int>(_rRecord.LogTime.Month), static_cast<int>(_rRecord.LogTime.Day),
- static_cast<int>(_rRecord.LogTime.Hours), static_cast<int>(_rRecord.LogTime.Minutes), static_cast<int>(_rRecord.LogTime.Seconds), static_cast<int>(_rRecord.LogTime.NanoSeconds) );
+ snprintf( buffer, buffer_size, "%04" SAL_PRIdINT32 "-%02" SAL_PRIuUINT32 "-%02" SAL_PRIuUINT32 " %02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ".%09" SAL_PRIuUINT32,
+ static_cast<sal_Int32>(_rRecord.LogTime.Year), static_cast<sal_uInt32>(_rRecord.LogTime.Month), static_cast<sal_uInt32>(_rRecord.LogTime.Day),
+ static_cast<sal_uInt32>(_rRecord.LogTime.Hours), static_cast<sal_uInt32>(_rRecord.LogTime.Minutes), static_cast<sal_uInt32>(_rRecord.LogTime.Seconds), _rRecord.LogTime.NanoSeconds );
aLogEntry.appendAscii( buffer );
aLogEntry.append( " " );