[Libreoffice-commits] .: sal/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 4 07:01:56 PST 2012


 sal/inc/rtl/strbuf.hxx       |    2 +-
 sal/inc/rtl/string.hxx       |    2 +-
 sal/inc/rtl/stringconcat.hxx |   12 +++++++++---
 sal/inc/rtl/ustrbuf.hxx      |    2 +-
 sal/inc/rtl/ustring.hxx      |    4 ++--
 5 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit bda7beac5b9ea434ddd3185e71d253c9ba11c098
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Dec 4 15:55:14 2012 +0100

    sal: warning C4267: return: conversion from 'size_t' to 'int'...
    
    ... possible loss of data.
    
    Minimal fix that inserts casts when calling strlen; other option would
    be to change all length() to return size_t...
    
    Change-Id: I5d1e0b0c7175a1957aad3acd89884fcd37089454

diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 5f1c351..ed627ce 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -228,7 +228,7 @@ public:
     template< typename T1, typename T2 >
     OStringBuffer( const OStringConcat< T1, T2 >& c )
     {
-        const int l = c.length();
+        const sal_Int32 l = c.length();
         rtl_String* buffer = NULL;
         nCapacity = l + 16;
         rtl_string_new_WithLength( &buffer, nCapacity );
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index f1e51b7..cbd4b9a 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -260,7 +260,7 @@ public:
     template< typename T1, typename T2 >
     OString( const OStringConcat< T1, T2 >& c )
     {
-        const int l = c.length();
+        const sal_Int32 l = c.length();
         rtl_String* buffer = NULL;
         rtl_string_new_WithLength( &buffer, l );
         if (l != 0)
diff --git a/sal/inc/rtl/stringconcat.hxx b/sal/inc/rtl/stringconcat.hxx
index bf0244a..2b4fc31 100644
--- a/sal/inc/rtl/stringconcat.hxx
+++ b/sal/inc/rtl/stringconcat.hxx
@@ -100,7 +100,9 @@ sal_Unicode* addDataUString( sal_Unicode* buffer, const sal_Unicode* str )
 template<>
 struct ToStringHelper< const char* >
     {
-    static int length( const char* str ) { return strlen( str ); }
+    static int length( const char* str ) {
+        return sal::static_int_cast<int>(strlen( str ));
+    }
     static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); }
     static const bool allowOStringConcat = true;
     static const bool allowOUStringConcat = false;
@@ -109,7 +111,9 @@ struct ToStringHelper< const char* >
 template<>
 struct ToStringHelper< char* >
     {
-    static int length( const char* str ) { return strlen( str ); }
+    static int length( const char* str ) {
+        return sal::static_int_cast<int>(strlen( str ));
+    }
     static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); }
     static const bool allowOStringConcat = true;
     static const bool allowOUStringConcat = false;
@@ -118,7 +122,9 @@ struct ToStringHelper< char* >
 template< int N >
 struct ToStringHelper< char[ N ] >
     {
-    static int length( const char str[ N ] ) { return strlen( str ); }
+    static int length( const char str[ N ] ) {
+        return sal::static_int_cast<int>(strlen( str ));
+    }
     static char* addData( char* buffer, const char str[ N ] ) { return addDataCString( buffer, str ); }
     static sal_Unicode* addData( sal_Unicode* buffer, const char str[ N ] ) { return addDataLiteral( buffer, str, N - 1 ); }
     static const bool allowOStringConcat = true;
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index f49f7f8..b8f2d05 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -220,7 +220,7 @@ public:
     template< typename T1, typename T2 >
     OUStringBuffer( const OUStringConcat< T1, T2 >& c )
     {
-        const int l = c.length();
+        const sal_Int32 l = c.length();
         rtl_uString* buffer = NULL;
         nCapacity = l + 16;
         rtl_uString_new_WithLength( &buffer, nCapacity ); // TODO this clears, not necessary
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index 4408dfd..3629511 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -328,7 +328,7 @@ public:
     template< typename T1, typename T2 >
     OUString( const OUStringConcat< T1, T2 >& c )
     {
-        const int l = c.length();
+        const sal_Int32 l = c.length();
         rtl_uString* buffer = NULL;
         rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary
         if (l != 0)
@@ -1592,7 +1592,7 @@ public:
 
       @since LibreOffice 4.0
     */
-    OUString replaceAll(OUString const & from, OUString const & to, int fromIndex = 0) const {
+    OUString replaceAll(OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const {
         rtl_uString * s = 0;
         rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
         return OUString(s, SAL_NO_ACQUIRE);


More information about the Libreoffice-commits mailing list