external/curl/UnpackedTarball_curl.mk | 6 ++++ external/curl/clang-cl.patch.0 | 11 ++++++++ sal/osl/w32/backtrace.cxx | 19 ++++++++------- sal/osl/w32/file.cxx | 42 ++++++++++++++++++++++++---------- vcl/win/app/salinst.cxx | 2 - vcl/win/app/saltimer.cxx | 2 - 6 files changed, 60 insertions(+), 22 deletions(-)
New commits: commit 540d5e00714feef70d896d8856dc33db694e6e4b Author: Stephan Bergmann <[email protected]> Date: Fri Oct 27 16:08:15 2017 +0200 loplugin:rangedforcopy (clang-cl) Change-Id: I468d951007089fefc235e245c3cb4baea4aa51f7 diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 68ad7deb994d..40be2b1e4180 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -837,7 +837,7 @@ bool WinSalInstance::AnyInput( VclInputFlags nType ) ~VclInputFlags(VclInputFlags::KEYBOARD | VclInputFlags::TIMER); std::vector<MsgRange> aMsgRangeList( GetOtherRanges( nOtherType ) ); - for ( MsgRange aRange : aMsgRangeList ) + for ( MsgRange const & aRange : aMsgRangeList ) if ( PeekMessageW( &aMsg, nullptr, aRange.nStart, aRange.nEnd, PM_NOREMOVE | PM_NOYIELD ) ) return true; commit 6f95909b3351451f96fb40ef6b2c21580d7a4c64 Author: Stephan Bergmann <[email protected]> Date: Fri Oct 27 16:07:30 2017 +0200 loplugin:redundantcast (clang-cl) Change-Id: Ib6b314cc94d57ef9a643c14440427a38a9de15fe diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx index 9c67e841956e..d23c7344ef31 100644 --- a/vcl/win/app/saltimer.cxx +++ b/vcl/win/app/saltimer.cxx @@ -133,7 +133,7 @@ void CALLBACK SalTimerProc(PVOID data, BOOLEAN) { __try { - WinSalTimer *pTimer = reinterpret_cast<WinSalTimer*>( data ); + WinSalTimer *pTimer = static_cast<WinSalTimer*>( data ); BOOL const ret = PostMessageW( GetSalData()->mpInstance->mhComWnd, SAL_MSG_TIMER_CALLBACK, static_cast<WPARAM>(pTimer->GetNextEventVersion()), 0 ); commit 8959043f82e1d00abead9cbd809138d4f6521b14 Author: Stephan Bergmann <[email protected]> Date: Fri Oct 27 16:06:07 2017 +0200 -Werror,-Wtautological-constant-compare (clang-cl) ...fixed similarly to recent fixes to sal/osl/unx/file.cxx Change-Id: I2c82366095e156cd0085a8f60f54f8c822655dcc diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx index b8866322e940..408bd655e777 100644 --- a/sal/osl/w32/backtrace.cxx +++ b/sal/osl/w32/backtrace.cxx @@ -26,13 +26,19 @@ #include "backtraceasstring.hxx" +namespace { + +template<typename T> T clampToULONG(T n) { + auto const maxUlong = std::numeric_limits<ULONG>::max(); + return n > maxUlong ? static_cast<T>(maxUlong) : n; +} + +} + OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) { assert(maxDepth != 0); - auto const maxUlong = std::numeric_limits<ULONG>::max(); - if (maxDepth > maxUlong) { - maxDepth = static_cast<sal_uInt32>(maxUlong); - } + maxDepth = clampToULONG(maxDepth); OUStringBuffer aBuf; @@ -71,10 +77,7 @@ OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) std::unique_ptr<sal::BacktraceState> sal::backtrace_get(sal_uInt32 maxDepth) { assert(maxDepth != 0); - auto const maxUlong = std::numeric_limits<ULONG>::max(); - if (maxDepth > maxUlong) { - maxDepth = static_cast<sal_uInt32>(maxUlong); - } + maxDepth = clampToULONG(maxDepth); HANDLE hProcess = GetCurrentProcess(); SymInitialize( hProcess, nullptr, true ); diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index e64e5b306277..7c0b6674c23f 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -774,6 +774,14 @@ oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle) return result; } +namespace { + +//coverity[result_independent_of_operands] +template<typename T> bool exceedsMaxSIZE_T(T n) +{ return n > std::numeric_limits< SIZE_T >::max(); } + +} + oslFileError SAL_CALL osl_mapFile( oslFileHandle Handle, void** ppAddr, @@ -800,8 +808,7 @@ oslFileError SAL_CALL osl_mapFile( return osl_File_E_INVAL; *ppAddr = nullptr; - static SIZE_T const nLimit = std::numeric_limits< SIZE_T >::max(); - if (uLength > nLimit) + if (exceedsMaxSIZE_T(uLength)) return osl_File_E_OVERFLOW; SIZE_T const nLength = sal::static_int_cast< SIZE_T >(uLength); @@ -919,6 +926,19 @@ oslFileError SAL_CALL osl_writeFile( return result; } +LONGLONG const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); + +namespace { + +//coverity[result_independent_of_operands] +template<typename T> bool exceedsMaxLONGLONG(T n) +{ return n > g_limit_longlong; } + +template<typename T> bool exceedsMinLONGLONG(T n) +{ return n < std::numeric_limits<LONGLONG>::min(); } + +} + oslFileError SAL_CALL osl_readFileAt( oslFileHandle Handle, sal_uInt64 uOffset, @@ -933,8 +953,7 @@ oslFileError SAL_CALL osl_readFileAt( if ((pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE) == 0) return osl_File_E_SPIPE; - static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); - if (g_limit_longlong < uOffset) + if (exceedsMaxLONGLONG(uOffset)) return osl_File_E_OVERFLOW; LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); @@ -957,8 +976,7 @@ oslFileError SAL_CALL osl_writeFileAt( if ((pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE) == 0) return osl_File_E_SPIPE; - static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); - if (g_limit_longlong < uOffset) + if (exceedsMaxLONGLONG(uOffset)) return osl_File_E_OVERFLOW; LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); @@ -996,8 +1014,7 @@ oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_ if ((!pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; - static sal_Int64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); - if (g_limit_longlong < uOffset) + if (exceedsMaxLONGLONG(uOffset) || exceedsMinLONGLONG(uOffset)) return osl_File_E_OVERFLOW; LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset); @@ -1013,7 +1030,8 @@ oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_ nPos = sal::static_int_cast< LONGLONG >(pImpl->getPos()); if ((nOffset < 0) && (nPos < -1*nOffset)) return osl_File_E_INVAL; - if (g_limit_longlong < nPos + nOffset) + assert(nPos >= 0); + if (nOffset > g_limit_longlong - nPos) return osl_File_E_OVERFLOW; break; @@ -1021,7 +1039,8 @@ oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_ nPos = sal::static_int_cast< LONGLONG >(pImpl->getSize()); if ((nOffset < 0) && (nPos < -1*nOffset)) return osl_File_E_INVAL; - if (g_limit_longlong < nPos + nOffset) + assert(nPos >= 0); + if (nOffset > g_limit_longlong - nPos) return osl_File_E_OVERFLOW; break; @@ -1053,8 +1072,7 @@ oslFileError SAL_CALL osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize) if ((pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE) == 0) return osl_File_E_BADF; - static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); - if (g_limit_longlong < uSize) + if (exceedsMaxLONGLONG(uSize)) return osl_File_E_OVERFLOW; FileHandle_Impl::Guard lock(&(pImpl->m_mutex)); commit c1d0b19b43767e3ead431357e91949e1f548283e Author: Stephan Bergmann <[email protected]> Date: Fri Oct 27 16:03:02 2017 +0200 external/curl: Work around clang-cl not knowing /FD ("IDE Minimal Rebuild", according to <https://msdn.microsoft.com/en-us/library/6ce2bkt7.aspx>) Change-Id: I1b549c50bea4285bc6c89302f757f2e7e0bf1784 diff --git a/external/curl/UnpackedTarball_curl.mk b/external/curl/UnpackedTarball_curl.mk index b65b3d5cb300..1cdb64c0bca2 100644 --- a/external/curl/UnpackedTarball_curl.mk +++ b/external/curl/UnpackedTarball_curl.mk @@ -30,4 +30,10 @@ $(eval $(call gb_UnpackedTarball_add_patches,curl,\ )) endif +ifeq ($(OS)-$(COM_IS_CLANG),WNT-TRUE) +$(eval $(call gb_UnpackedTarball_add_patches,curl, \ + external/curl/clang-cl.patch.0 \ +)) +endif + # vim: set noet sw=4 ts=4: diff --git a/external/curl/clang-cl.patch.0 b/external/curl/clang-cl.patch.0 new file mode 100755 index 000000000000..2f7fe567460c --- /dev/null +++ b/external/curl/clang-cl.patch.0 @@ -0,0 +1,11 @@ +--- winbuild/MakefileBuild.vc ++++ winbuild/MakefileBuild.vc +@@ -60,7 +60,7 @@ + !ELSE + CC_NODEBUG = $(CC) /O2 /DNDEBUG + CC_DEBUG = $(CC) /Od /D_DEBUG /RTC1 /Z7 /LDd +-CFLAGS = /I. /I ../lib /I../include /nologo /W4 /wd4127 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL $(SOLARINC) ++CFLAGS = /I. /I ../lib /I../include /nologo /W4 /wd4127 /EHsc /DWIN32 /c /DBUILDING_LIBCURL $(SOLARINC) + !ENDIF + + LFLAGS = /nologo /machine:$(MACHINE) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
