[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 3 commits - android/mobile-config.py connectivity/source extensions/source sd/source svl/source vcl/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Sun Oct 6 17:09:53 UTC 2019
android/mobile-config.py | 4 ++--
connectivity/source/drivers/dbase/DTable.cxx | 13 +++++++------
connectivity/source/drivers/jdbc/ConnectionLog.cxx | 9 +++++----
extensions/source/logging/plaintextformatter.cxx | 9 +++++----
sd/source/filter/eppt/pptx-epptooxml.cxx | 5 +++--
svl/source/misc/lockfilecommon.cxx | 5 +++--
vcl/source/edit/texteng.cxx | 5 ++---
7 files changed, 27 insertions(+), 23 deletions(-)
New commits:
commit b32e7cd6faa4e04e24c0edb81e364d45511fbd37
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Dec 11 12:47:54 2018 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 6 18:58:54 2019 +0200
Make android/mobile-config.py compatible with Python 3
Change-Id: I079c4efd28e7e0d10ca6edf242ddd85b9294db08
Reviewed-on: https://gerrit.libreoffice.org/64962
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/android/mobile-config.py b/android/mobile-config.py
index c4be1e3c4028..ba892846e548 100755
--- a/android/mobile-config.py
+++ b/android/mobile-config.py
@@ -65,14 +65,14 @@ if __name__ == '__main__':
size = len(ET.tostring(child));
key = '%s/%s' % (package, section)
if key in main_xcd_discard:
- print 'removed %s - saving %d' % (key, size)
+ print('removed %s - saving %d' % (key, size))
saved = saved + size
to_remove.append(child)
for child in to_remove:
root.remove(child)
- print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)
+ print("saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total))
# Don't do pointless Word -> Writer and similar conversions when we have no UI.
nsDict = {
commit 825d8a5f8e4289ae895742901a36a419ad1c651e
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Jan 21 16:52:30 2019 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 6 18:56:44 2019 +0200
Simplify nXWidth initialization
...which happens to avoid an unhelpful -Werror=strict-overflow with GCC 7 and
--enable-optimized:
> vcl/source/edit/texteng.cxx: In member function ‘bool TextEngine::CreateLines(sal_uInt32)’:
> vcl/source/edit/texteng.cxx:2197:9: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Werror=strict-overflow]
> if ( nTmpWidth > nXWidth )
> ^~
Change-Id: Ia87933da6e38b8b462d2ea34c3db6a84c5840f92
Reviewed-on: https://gerrit.libreoffice.org/66690
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 859468fd9861..47ed32960866 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -2146,9 +2146,8 @@ bool TextEngine::CreateLines( sal_uInt32 nPara )
std::size_t nTmpPortion = pLine->GetStartPortion();
long nTmpWidth = mpDoc->GetLeftMargin();
// do not subtract margin; it is included in TmpWidth
- long nXWidth = mnMaxTextWidth ? mnMaxTextWidth : std::numeric_limits<long>::max();
- if ( nXWidth < nTmpWidth )
- nXWidth = nTmpWidth;
+ long nXWidth = std::max(
+ mnMaxTextWidth ? mnMaxTextWidth : std::numeric_limits<long>::max(), nTmpWidth);
// search for Portion that does not fit anymore into line
TETextPortion* pPortion = nullptr;
commit 297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jan 18 15:54:12 2019 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 6 18:56:07 2019 +0200
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 at redhat.com>
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 9e961cf793cb..535afd6660fe 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1823,16 +1823,17 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
aDate = ::dbtools::DBTypeConversion::toDate(thisColVal.getDouble());
else
aDate = thisColVal;
- char s[9];
+ char s[sizeof("-327686553565535")];
+ // reserve enough space for hypothetical max length
snprintf(s,
sizeof(s),
"%04d%02d%02d",
- static_cast<int>(aDate.Year),
- static_cast<int>(aDate.Month),
- static_cast<int>(aDate.Day));
+ static_cast<sal_Int32>(aDate.Year),
+ static_cast<sal_uInt32>(aDate.Month),
+ static_cast<sal_uInt32>(aDate.Day));
- // Exactly 8 bytes to copy:
- strncpy(pData,s,sizeof s - 1);
+ // Exactly 8 bytes to copy (even if s could hypothetically be longer):
+ memcpy(pData,s,8);
} break;
case DataType::INTEGER:
{
diff --git a/connectivity/source/drivers/jdbc/ConnectionLog.cxx b/connectivity/source/drivers/jdbc/ConnectionLog.cxx
index 329a0c185970..4f564c3fba6e 100644
--- a/connectivity/source/drivers/jdbc/ConnectionLog.cxx
+++ b/connectivity/source/drivers/jdbc/ConnectionLog.cxx
@@ -98,11 +98,12 @@ namespace comphelper { namespace log { namespace convert
OUString convertLogArgToString( const DateTime& _rDateTime )
{
- char buffer[ 30 ];
+ char buffer[ sizeof("-32768-65535-65535 65535:65535:65535.4294967295") ];
+ // reserve enough space for hypothetical max length
const size_t buffer_size = sizeof( buffer );
- snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i",
- static_cast<int>(_rDateTime.Year), static_cast<int>(_rDateTime.Month), static_cast<int>(_rDateTime.Day),
- static_cast<int>(_rDateTime.Hours), static_cast<int>(_rDateTime.Minutes), static_cast<int>(_rDateTime.Seconds), static_cast<int>(_rDateTime.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>(_rDateTime.Year), static_cast<sal_uInt32>(_rDateTime.Month), static_cast<sal_uInt32>(_rDateTime.Day),
+ static_cast<sal_uInt32>(_rDateTime.Hours), static_cast<sal_uInt32>(_rDateTime.Minutes), static_cast<sal_uInt32>(_rDateTime.Seconds), _rDateTime.NanoSeconds );
return OUString::createFromAscii( buffer );
}
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( " " );
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 9254d9010c34..ff6acdd1254e 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -981,9 +981,10 @@ bool PowerPointExport::WriteComments(sal_uInt32 nPageNum)
Reference< XText > xText(xAnnotation->getTextRange());
sal_Int32 nLastIndex;
sal_Int32 nId = GetAuthorIdAndLastIndex(xAnnotation->getAuthor(), nLastIndex);
- char cDateTime[32];
+ char cDateTime[sizeof("-32768-65535-65535T65535:65535:65535.4294967295")];
+ // reserve enough space for hypothetical max length
- snprintf(cDateTime, 31, "%02d-%02d-%02dT%02d:%02d:%02d.%09" SAL_PRIuUINT32, aDateTime.Year, aDateTime.Month, aDateTime.Day, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
+ snprintf(cDateTime, sizeof cDateTime, "%02" SAL_PRIdINT32 "-%02" SAL_PRIuUINT32 "-%02" SAL_PRIuUINT32 "T%02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ".%09" SAL_PRIuUINT32, sal_Int32(aDateTime.Year), sal_uInt32(aDateTime.Month), sal_uInt32(aDateTime.Day), sal_uInt32(aDateTime.Hours), sal_uInt32(aDateTime.Minutes), sal_uInt32(aDateTime.Seconds), aDateTime.NanoSeconds);
pFS->startElementNS(XML_p, XML_cm,
XML_authorId, I32S(nId),
diff --git a/svl/source/misc/lockfilecommon.cxx b/svl/source/misc/lockfilecommon.cxx
index f0a1db6864e0..175220a532eb 100644
--- a/svl/source/misc/lockfilecommon.cxx
+++ b/svl/source/misc/lockfilecommon.cxx
@@ -223,8 +223,9 @@ OUString LockFileCommon::GetCurrentLocalTime()
oslDateTime aDateTime;
if ( osl_getDateTimeFromTimeValue( &aLocTime, &aDateTime ) )
{
- char pDateTime[20];
- sprintf( pDateTime, "%02d.%02d.%4d %02d:%02d", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes );
+ char pDateTime[sizeof("65535.65535.-32768 65535:65535")];
+ // reserve enough space for hypothetical max length
+ sprintf( pDateTime, "%02" SAL_PRIuUINT32 ".%02" SAL_PRIuUINT32 ".%4" SAL_PRIdINT32 " %02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32, sal_uInt32(aDateTime.Day), sal_uInt32(aDateTime.Month), sal_Int32(aDateTime.Year), sal_uInt32(aDateTime.Hours), sal_uInt32(aDateTime.Minutes) );
aTime = OUString::createFromAscii( pDateTime );
}
}
More information about the Libreoffice-commits
mailing list