[Libreoffice-commits] .: unotest/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Dec 10 02:08:05 PST 2012
unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
New commits:
commit aaeba64fa50d92a219106dab10ad17d8c34fbfa3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Dec 10 11:07:42 2012 +0100
-Werror,-Wtautological-constant-out-of-range-compare
Change-Id: I4356413b23fdbaaa1bf2e94ad7aed3ceed1f9261
diff --git a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
index b28e075..3cd43f4 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 <limits>
#include <string>
#include <iostream>
#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
More information about the Libreoffice-commits
mailing list