From aaeba64fa50d92a219106dab10ad17d8c34fbfa3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 10 Dec 2012 11:07:42 +0100 Subject: -Werror,-Wtautological-constant-out-of-range-compare Change-Id: I4356413b23fdbaaa1bf2e94ad7aed3ceed1f9261 --- .../source/cpp/unoexceptionprotector/unoexceptionprotector.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'unotest') diff --git a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx index b28e075f4ff3..3cd43f480cbd 100644 --- a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx +++ b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx @@ -17,11 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include #include #include #include "boost/noncopyable.hpp" +#include "boost/static_assert.hpp" #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Exception.hpp" #include "cppuhelper/exc_hlp.hxx" @@ -39,12 +39,10 @@ namespace { // Best effort conversion: std::string convert(rtl::OUString const & s16) { rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding())); + BOOST_STATIC_ASSERT(sizeof (sal_Int32) <= sizeof (std::string::size_type)); + // ensure following cast is legitimate return std::string( - s8.getStr(), - ((static_cast< sal_uInt32 >(s8.getLength()) - > std::numeric_limits< std::string::size_type >::max()) - ? std::numeric_limits< std::string::size_type >::max() - : static_cast< std::string::size_type >(s8.getLength()))); + s8.getStr(), static_cast< std::string::size_type >(s8.getLength())); } class Prot : public CppUnit::Protector, private boost::noncopyable -- cgit